home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / xdsn217.zip / DOC / xdsug.inf (.txt) < prev    next >
OS/2 Help File  |  1996-07-08  |  233KB  |  8,421 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Disclaimer ΓòÉΓòÉΓòÉ
  3.  
  4. This on-line document was generated automatically from its printed version 
  5. LaTeX source. Some places in the document (especially tables) may look ugly due 
  6. to the conversion program limits. These problems are being worked on and are 
  7. supposed to be solved in the final release. 
  8.  
  9.  
  10. ΓòÉΓòÉΓòÉ 2. Title Page ΓòÉΓòÉΓòÉ
  11.  
  12.  xTech Development System 
  13.  
  14.  Native XDS v2.17 
  15. for 
  16. IBM Operating System/2 
  17.  
  18.  User's Guide 
  19.  
  20.  xTech Ltd, 1996 
  21.  
  22. XDS software and documentation copyright (c) 1991-1996 xTech Ltd. (xTech). 
  23.  
  24. Information in this document is subject to change without notice and does not 
  25. represent a commitment on the part of xTech. 
  26.  
  27. All rights reserved. You may use the enclosed software on a single computer; 
  28. transfer the software from one computer to another, provided that the software 
  29. is used on only one computer at a time and that you remove any copies of the 
  30. software on the computer from which the copies were made; make copies of the 
  31. software for backup purposes only. 
  32.  
  33. XDS software and documentation have been tested and reviewed. Nevertheless, 
  34. xTech makes no warranty or representation, either express or implied, with 
  35. respect to the software and documentation included with XDS. In no event will 
  36. xTech be liable for direct, indirect, special, incidental or consequential 
  37. damages resulting from any defect in the software or documentation included 
  38. with this product. In particular, xTech shall have no liability for any 
  39. programs or data used with this product, including the cost of recovering 
  40. programs or data. 
  41.  
  42. XDS is a trademark of xTech Ltd. 
  43.  
  44. IBM, Operating System/2, OS/2, Presentation Manager, C Set/2 are trademarks of 
  45. IBM Corporation. 
  46.  
  47. All trademarks and copyrights mentioned in this documentation are the property 
  48. of their respective holders. 
  49.  
  50.  
  51. ΓòÉΓòÉΓòÉ 3. About XDS ΓòÉΓòÉΓòÉ
  52.  
  53.      Welcome to XDS 
  54.      Conventions used in this manual 
  55.  
  56.  
  57. ΓòÉΓòÉΓòÉ 3.1. Welcome to XDS ΓòÉΓòÉΓòÉ
  58.  
  59. xTech development system (XDSTM) is a professional system available for most 
  60. popular platforms, from Intel x86-based PCs (PC/MS-DOS, Windows 95, Windows NT, 
  61. OS/2, Linux versions) to various Unix workstations (Sun, HP, DEC, MIPS) etc. 
  62. XDS provides an uniform programming environment for all mentioned platforms and 
  63. allows to design and implement truly portable software. 
  64.  
  65. The system contains both Modula-2 and Oberon-2 compilers. These languages are 
  66. often called ``safe'' and ``modular''. The principle innovation of the language 
  67. Modula-2 was the module concept, information hiding and separate compilation. 
  68.  
  69. Oberon-2 is an object-oriented programming (OOP) language based on Modula-2. 
  70. With the introduction of object-oriented facilities, extensible project design 
  71. became much easier. Meanwhile Oberon-2 is quite simple and easy to learn and 
  72. use, unlike other OOP languages such as C++ or Smalltalk. 
  73.  
  74. The XDS Modula-2 compiler implements ISO standard of Modula-2. The ISO standard 
  75. library set is accessible from both Modula-2 and Oberon-2. 
  76.  
  77. XDS is based on a platform-independent front-end for both source languages 
  78. which performs all syntactic and semantic checks on the source program. The 
  79. compiler builds an internal representation of the compilation unit in memory 
  80. and performs platform-independent analysis and optimizations. After that the 
  81. compiler emits output code. It can be either a native code for the target 
  82. platform or a text in the ANSI C language. The ANSI C code generation is 
  83. available for all platforms. A number of platforms for which a native code 
  84. compiler is available is constantly extended. 
  85.  
  86. Moving to a new language usually means throwing away or rewriting your existing 
  87. library set which could have been the work of many years. XDS allows the 
  88. programmer to mix Modula-2, Oberon-2, C and Assembler modules and libraries in 
  89. a single project. 
  90.  
  91. XDS includes standard ISO and PIM libraries along with a set of utility 
  92. libraries and an interface to the ANSI C library set. 
  93.  
  94. XDS compilers for OS/2 produce highly optimized 32-bit code and debug 
  95. information in the Codeview format. The complete OS/2 32-bit API (including 
  96. Presentation Manager) support is provided for both Modula-2 and Oberon-2 
  97. programs. 
  98.  
  99.  
  100. ΓòÉΓòÉΓòÉ 3.2. Conventions used in this manual ΓòÉΓòÉΓòÉ
  101.  
  102.      Language descriptions 
  103.      Source code fragments 
  104.  
  105.  
  106. ΓòÉΓòÉΓòÉ 3.2.1. Language descriptions ΓòÉΓòÉΓòÉ
  107.  
  108. Where formal descriptions for language syntax constructions appear, an extended 
  109. Backus-Naur Formalism (EBNF) is used. 
  110.  
  111. These descriptions are set in the Courier font. 
  112.  
  113. Text= Text [{Text}] | Text.
  114.  
  115. In EBNF, Brackets [ and ] denote optionality of the enclosed expression, braces 
  116. { and } denote repetition (possibly 0 times), and the line | denotes other 
  117. possible valid descriptions. 
  118.  
  119. Non-terminal symbols start with an upper case letter (e.g. Statement). Terminal 
  120. symbols either start with a lower case letter (e.g. ident), or are written in 
  121. all upper case letters (e.g. BEGIN), or are enclosed within quotation marks 
  122. (e.g. ":="). 
  123.  
  124.  
  125. ΓòÉΓòÉΓòÉ 3.2.2. Source code fragments ΓòÉΓòÉΓòÉ
  126.  
  127. When fragments of a source code are used for examples or appear within a text 
  128. they are set in the Courier font. 
  129.  
  130. MODULE Example;
  131.  
  132. IMPORT InOut;
  133.  
  134. BEGIN
  135.   InOut.WriteString("This is an example");
  136.   InOut.WriteLn;
  137. END Example.
  138.  
  139.  
  140. ΓòÉΓòÉΓòÉ 4. Configuring XDS ΓòÉΓòÉΓòÉ
  141.  
  142.      System search paths 
  143.      Working configuration 
  144.      XDS memory usage 
  145.      Directory hierarchies 
  146.      XDS search paths 
  147.      Options 
  148.      Configuration file 
  149.      Filename extensions 
  150.      More about XDS environment 
  151.      Customize XDS messages 
  152.      XDS and your C compiler 
  153.  
  154.  
  155. ΓòÉΓòÉΓòÉ 4.1. System search paths ΓòÉΓòÉΓòÉ
  156.  
  157. In order that your operating system should know where to find the executable 
  158. binary files which constitute the XDS package, you must set your operating 
  159. system search paths appropriately. See your on-line documentation. 
  160.  
  161.  
  162. ΓòÉΓòÉΓòÉ 4.2. Working configuration ΓòÉΓòÉΓòÉ
  163.  
  164. The working configuration of XDS includes an utility (xc), that combines 
  165. Modula-2 and Oberon-2 compilers, and a set of the system files A name of a 
  166. system file is constructed from the name of the main utility and standard 
  167. filename extension. If you rename the xc utility, you should also rename all 
  168. system files.: 
  169.  
  170. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  171.  xc.red Search path redirection file (See Redirection file)
  172.  
  173.  xc.cfg Configuration file (See Configuration file)
  174.  
  175.  xc.msg Contains texts of error messages (See Customize XDS messages)
  176. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  177.  
  178. When invoked the xc tries to locate the xc.red file in the current directory or 
  179. in the directory where XDS is placed. 
  180.  
  181. Other system files are sought by paths defined by xc.red. If xc.red is not 
  182. found, or it does not contain paths for a system file, the system file is 
  183. sought in the current directory or in the directory where XDS is placed. 
  184.  
  185. The configuration file contains setting that are relevant for all projects. A 
  186. project specific settings are defined in a project file (See Project files). A 
  187. so-called template file is used to simplify the process of building program 
  188. (See Template files). 
  189.  
  190. The configuration and redirection file, project and template files define a 
  191. working environment for a XDS user. The common features of all these files are 
  192. described in More about XDS environment. 
  193.  
  194. The portable software development is one of the main goals of XDS. To achieve 
  195. the goal not only source text should be portable between various platforms, but 
  196. the environment also. The XDS introduces a portable notation for file names 
  197. that may be used in all system files and on the command line. The portable 
  198. notation combines MS-DOS and Unix notations (file names are case sensitive): 
  199.  
  200.         [drive letter:] unix file name
  201.  
  202. Examples 
  203.  
  204.         c:/xds/bin
  205.         /mnt/users/alex/cur_pro
  206.         cur_pro/sources
  207.  
  208. Along with the base directory macro (See More about XDS environment) this 
  209. portable notation allows to write all environment files in a platform 
  210. independent and position independent manner. 
  211.  
  212.  
  213. ΓòÉΓòÉΓòÉ 4.3. XDS memory usage ΓòÉΓòÉΓòÉ
  214.  
  215. The XDS compilers are written itself in Oberon-2We use XDS for all our 
  216. developments.. As any other Oberon programs the compilers use garbage collector 
  217. to deallocate memory. Most operating systems (such as Unix, OS/2, Windows NT 
  218. and Windows 95) provide virtual memory which can be significantly larger than 
  219. the physical memory. If the amount of memory used by an Oberon-2 program is 
  220. larger than the amount of physical memory, the garbage collector is 
  221. inefficient. Thus, it is important to restrict the amount of memory that can be 
  222. used by an Oberon-2 program. As a rule, such restrictions are set in the 
  223. configuration or project file (See HEAPLIMIT and GCTHRESHOLD equations). 
  224.  
  225. For the compilers itself, two equations (COMPILERHEAP and COMPILERTHRES) should 
  226. be used to control the amount of memory to use. These equations are set in the 
  227. configuration file (xc.cfg). We recommend to set these equations according to 
  228. the amount of the physical memory in your computer: 
  229.  
  230. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  231.  RAM in megabytes  COMPILERHEAP  COMPILERTHRES
  232.  
  233.  2-8               4000000       2000000
  234.  
  235.  8-16              6000000       3000000
  236.  
  237.  16-?              8000000       4000000
  238. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  239.  
  240. It may be necessary to increase COMPILERHEAP if you get the out of memory 
  241. message. It is very unlikely, if the COMPILERHEAP is set to 8 megabytes. Your 
  242. compilation unit should be very large to exceed this memory limit. 
  243.  
  244. Vice versa, if you see unusually intensive disk activity when compiling your 
  245. program it may indicate that the value of the COMPILERHEAP equation is too 
  246. large for your system configuration. 
  247.  
  248.  
  249. ΓòÉΓòÉΓòÉ 4.4. Directory hierarchies ΓòÉΓòÉΓòÉ
  250.  
  251. XDS gives you complete freedom over where you keep both your source code files 
  252. and any files which XDS itself creates for further use. It is advisable to work 
  253. in a project oriented fashion - i.e. have a separate directory hierarchy for 
  254. each individual project. 
  255.  
  256. Due to the re-usable nature of modules written in Modula-2 or Oberon-2, it is 
  257. wise to keep a separate directory for those files which are to be made 
  258. available to all projects. We will call such files the library files. 
  259.  
  260. We recommend you to have a separate working directory for each project. For 
  261. example, to create a directory structure for a project called myproj: 
  262.  
  263. mkdir myproj
  264.  
  265. Set your current working directory to this new directory 
  266.  
  267. cd myproj
  268.  
  269. You can also create subdirectories to store the symbol files and generated code 
  270. files. We recommend to use the script xdsuser or customized version of it to 
  271. create all subdirectories and system files (e.g. xc.red). 
  272.  
  273.  
  274. ΓòÉΓòÉΓòÉ 4.5. XDS search paths ΓòÉΓòÉΓòÉ
  275.  
  276. Upon activation, XDS looks for a file called xc.red - the redirection file. 
  277. This file defines the paths by which all other files are located. If the 
  278. redirection file is not found in the current directory it is sought in the 
  279. directory where XDS executable is placed. 
  280.  
  281.      Redirection file 
  282.      Regular expression 
  283.  
  284.  
  285. ΓòÉΓòÉΓòÉ 4.5.1. Redirection file ΓòÉΓòÉΓòÉ
  286.  
  287. A redirection file consists of several lines of the formSee also More about XDS 
  288. environment: 
  289.  
  290.    pattern = directory {";" directory}
  291.  
  292. It is possible to put comment lines into the redirection file. A comment line 
  293. should start from "%" symbol. A pattern is a regular expression which all 
  294. filenames used by XDS will be compared with. A pattern may contain the wildcard 
  295. symbols '*' and '?', where 
  296.  
  297.  *         stands for any (possibly empty) string, 
  298.  
  299.  ?         stands for any single character. 
  300.  
  301.  For a full description of extended use of wildcards see Regular expression. 
  302.  
  303.  A portable notation is used for directory names or paths (See Working 
  304.  configuration). A path may be absolute or relative, i.e. may consist of full 
  305.  names such as 
  306.  
  307.   /usr/myproj/def
  308.  
  309.  or of names relative to the current directory, such as 
  310.  
  311.   def
  312.  
  313.  denoting the directory def which is a subdirectory of the current working 
  314.  directory. A single dot as a pathname represents the current working 
  315.  directory, a double dot represents the parent, i.e. the directory which has 
  316.  the current working directory as a subdirectory. 
  317.  
  318.  The base directory macro $! can be used in a directory name. It denotes the 
  319.  path to the redirection file. If the redirection file is placed in the 
  320.  /usr/alex directory then $!/sym denotes /usr/alex/sym, while $!/.. denotes 
  321.  /usr directory. 
  322.  
  323.  For any file, its name is sequentially compared with the patterns of each 
  324.  line. If a match is found, then the file is sought for in the first of the 
  325.  directories listed on that line, then in the second directory and so on until 
  326.  either the file is found, or there are no more directories to search or there 
  327.  are no more patterns to match. 
  328.  
  329.  If XDS cannot find a file which is needed for correct execution, e.g. a 
  330.  necessary symbol file, then it will terminate with an appropriate error 
  331.  message. 
  332.  
  333.  When creating a file XDS also uses redirection, and its behavior is determined 
  334.  by the OVERWRITE option. If the option is set and a file is found, then any 
  335.  updates to this file will be re-written to the directory in which it was 
  336.  found. 
  337.  
  338.  If no file of the same name as the one which XDS needs to create is found or 
  339.  the OVERWRITE option is set off, then the file will be created in the 
  340.  directory which appears first in the search path list appropriate to the 
  341.  filename pattern. 
  342.  
  343.  If no pattern matching a given filename can be found in the xc.red file, then 
  344.  the file will be read from (or written to) the current working directory. 
  345.  
  346.  Note: If a pattern matching a given filename is found then XDS will never look 
  347.  into the current directory, unless it is explicitly specified in the search 
  348.  path. 
  349.  
  350.  The following entry in xc.red would be appropriate for searching for the 
  351.  symbol files (provided a symbol file has a .sym extension. 
  352.  
  353.   *.sym=sym;c:/xds/sym;.
  354.  
  355.  Using the above redirection the compiler will first search for symbol files in 
  356.  the directory sym which is a subdirectory of the current working directory; 
  357.  then in the directory storing the XDS library symbol files and then in the 
  358.  current directory. 
  359.  Example of the redirection file: 
  360.  
  361.   xc.msg = /xds/bin
  362.   *.mod = mod
  363.   *.def = def
  364.   *.ob2 = oberon
  365.   *.sym = sym; /xds/sym
  366.  
  367.  
  368. ΓòÉΓòÉΓòÉ 4.5.2. Regular expression ΓòÉΓòÉΓòÉ
  369.  
  370. A regular expression is a string containing certain special symbols. These are 
  371.  
  372.  *         denotes an arbitrary sequence of any characters, possibly empty 
  373.            (equivalent to {\000-\377} expression) 
  374.  
  375.  ?         denotes an arbitrary single character; (equivalent to [\000-\377] 
  376.            expression) 
  377.  
  378.  [characters] denotes one of the listed characters 
  379.  
  380.  {characters} denotes an arbitrary sequence of the listed characters; 
  381.  
  382.  \nnn      denotes the ASCII character with octal code nnn where n is [0-7]. 
  383.  
  384.  &         denotes the logical operation AND; 
  385.  
  386.  |         denotes the logical operation OR; 
  387.  
  388.  ^         denotes the logical operation NOT; 
  389.  
  390.  (..)      sets the priority of operations; 
  391.  
  392.  A sequence of the form a-b used within either [] or {} brackets denotes all 
  393.  ASCII characters from a to b. 
  394.  Examples 
  395.  
  396.  *.def 
  397.  
  398.            all files whose extension is .def 
  399.  
  400.  project.* 
  401.  
  402.            files whose name is project with an arbitrary extension 
  403.  
  404.  *.def|*.mod 
  405.  
  406.            files whose extension is either .def or .mod 
  407.  
  408.  \{a-z\}*X.def 
  409.  
  410.            files starting with any sequence of letters, ending in one final "X" 
  411.            and having the extension .def. 
  412.  
  413.  
  414. ΓòÉΓòÉΓòÉ 4.6. Options ΓòÉΓòÉΓòÉ
  415.  
  416. A rich set of XDS options allows one to control the source language, code 
  417. generation and internal limits and settings. We distinguish between boolean 
  418. options (or just options) and equations. An option can be set ON (TRUE) or OFF 
  419. (FALSE), while an equation value is a string. In this chapter we describe only 
  420. the syntax of setup directive. The full list of XDS options and equations is 
  421. provided in the Chapter Compiler Options and Equations. 
  422.  
  423. Options and equations may be set in the configuration file (See Configuration 
  424. file), on the command line (See XDS operation modes) and in the project file 
  425. (See Project files). Options may also be set in the source text (See Source 
  426. code directives). 
  427.  
  428. The same syntax of a setup directive is used in the configuration and project 
  429. file and on the command line. The only difference is that arbitrary spaces are 
  430. permitted in files, but not on the command line. Option and equation names are 
  431. case independent. 
  432.  
  433. SetupDirective   = DeclareOption
  434.                  | DeclareSynonym
  435.                  | SetOption
  436.                  | DeclareEquation
  437.                  | SetEquation
  438. DeclareOption    = '-' name ':' [ '+' | '-' ]
  439. DeclareSynonym   = '-' name ':=' name
  440. SetOption        = '-' name '+'| '-' name '-'
  441. DeclareEquation  = '-' name '!' [ value ]
  442. SetEquation      = '-' name '=' [ value ]
  443.  
  444. All options and equations used by XDS are predeclared. 
  445.  
  446. The DeclareSynonym directive allows one to use a desirable name (e.g. shorter 
  447. name) for some option. 
  448. Examples 
  449.  
  450. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  451.  Directive       Meaning
  452.  
  453.  -m2extensions   M2EXTENSION is set OFF
  454.  
  455.  -M2Extensions+  M2EXTENSION is set ON
  456.  
  457.  -debug:         DEBUG is declared and set OFF
  458.  
  459.  -DemoVersion:+  DEMOVERSION is declared and set ON
  460.  
  461.  -T:=CheckIndex  the T is declared as synonym to CHECKINDEX
  462.  
  463.  -Vers!1.0       VERS is declared and set to "1.0"
  464.  
  465.  -Oberon=o2      OBERON is set to "o2"
  466. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  467.  
  468. Note: The syntax of the setup directive described above was introduced in XDS 
  469. v2.04. The new syntax is more portable, e.g. it can be used in the MacOS/MPW 
  470. shell command line. However, the old syntax is still supported to provide 
  471. backward compatibility: 
  472.  
  473. DeclareOption  = ':' name [ '+' | '-' ]
  474. DeclareSynonym = ':' name '=' name
  475. SetOption_on   = '+' name | '-' name
  476. SetEquation    = '#' name ['='] value
  477.  
  478.  
  479. ΓòÉΓòÉΓòÉ 4.7. Configuration file ΓòÉΓòÉΓòÉ
  480.  
  481. The configuration file can be used to set the values of options and equations 
  482. (See Chapter Compiler Options and Equations). Every line in the configuration 
  483. file can contain only one compiler option or equation setup directive (See 
  484. Options). Arbitrary spaces are permitted. A character "%" is the comment 
  485. character; it causes the rest of the line to be discarded. Note: the comment 
  486. character can not be used when setting an equation. 
  487.  
  488. A configuration file can contain several LOOKUP equations, which allows us to 
  489. change the search paths, defined in the redirection file: 
  490.  
  491. -LOOKUP = pattern = directory {";" directory}
  492.  
  493. Example of the configuration file: 
  494.  
  495.   % this is a comment line
  496.   % Set equation:
  497.    - BSDef = df
  498.   % Set redirection:
  499.    -lookup = *.mod = mod
  500.    -lookup = *.sym = sym; /xds/sym
  501.   % Set predeclared options:
  502.    - RangeCheck -   % turn range checks off
  503.    - M2EXTENSIONS + % allow Modula-2 extensions
  504.   % Declare new options:
  505.    -i80486:+
  506.    -i80386:-
  507.    -i80286:         % is equal to -80286:-
  508.   % Declare synonym:
  509.    -N := checknil
  510.    -N               % disallow NIL checks
  511.   % end of configuration file
  512.  
  513. In the above example the XDS will search for the files with mod and sym 
  514. extensions using the search paths defined in the configuration file. The search 
  515. paths defined in the redirection file will be used for all other extensions. 
  516.  
  517.  
  518. ΓòÉΓòÉΓòÉ 4.8. Filename extensions ΓòÉΓòÉΓòÉ
  519.  
  520. XDS allows you to define what you want to be the standard extensions to each 
  521. particular type of file. For instance you may prefer your Oberon-2 source code 
  522. texts to be extended with a .o2 or a .ob2. 
  523.  
  524. It is wise to either use the traditional extensions or at least the extensions 
  525. which describe the kind of file they refer to, for example, using .def and .mod 
  526. for Modula-2 modules, .ob2 for Oberon-2 modules etc. It is also wise to keep 
  527. the extensions the same across all of your projects. 
  528.  
  529. Certain other factors must also influence your decisions. By tradition, 
  530. Oberon-2 pseudo-definition modules (as created by the browser) are extended 
  531. with a .def. With XDS, this may conflict with the extension used for Modula-2 
  532. definition modules. Therefore, by default the browser uses the extension .odf. 
  533.  
  534. The following filename extensions are usually defined in the configuration 
  535. file: 
  536.  
  537. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  538.  DEF     extension for Modula-2 definition modules
  539.  
  540.  MOD     extension for Modula-2 implementation modules
  541.  
  542.  OBERON  extension for Oberon-2 modules
  543.  
  544.  BSDEF   extension for Oberon-2 pseudo definition modules
  545.  
  546.  CODE    extension for generated code files
  547.  
  548.  SYM     extension for symbol files
  549. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  550.  
  551. See table Examples for the full list of file extensions. 
  552. Example (file extension entries in xc.cfg): 
  553.  
  554.    -def     = def
  555.    -mod     = mod
  556.    -oberon  = ob2
  557.    -sym     = sym
  558.  
  559.  
  560. ΓòÉΓòÉΓòÉ 4.9. More about XDS environment ΓòÉΓòÉΓòÉ
  561.  
  562. The XDS user environment consists of 
  563.  
  564.      the redirection file 
  565.  
  566.      the configuration file 
  567.  
  568.      a project file for each project 
  569.  
  570.      template files 
  571.  
  572.  The information provided in this section can be applied to any of these files. 
  573.  
  574.  Each file is a sequence of lines. The symbol \ at the end of a line denotes 
  575.  the line continuation. The following features may be used in the files: 
  576.  
  577.      a portable notation for file names (See Working configuration). 
  578.  
  579.      the base directory macro ($!) This macro denotes the directory on which 
  580.       the file containing the macro is placed. 
  581.  
  582.      a set of directives, starting from !. 
  583.  
  584.  The directive has the following syntax (all keywords are case independent): 
  585.  
  586.   Directive = "!" "NEW" SetOption | SetEquation
  587.             | "!" "SET" SetOption | SetEquation
  588.             | "!" "MESSAGE" Expression
  589.             | "!" "IF" Expression "THEN"
  590.             | "!" "ELSIF" Expression "THEN"
  591.             | "!" "ELSE"
  592.             | "!" "END".
  593.   SetOption   = ident ( "+" | "-" ).
  594.   SetEquation = ident = { character }.
  595.  
  596.  The NEW directive declares a new option or equation. The SET directive changes 
  597.  the value of an option or equation. The MESSAGE directive prints a value of 
  598.  expression. The IF directive allows to process or skip portions of files 
  599.  according the value of expression. 
  600.  
  601.   Expression = Simple [ Relation Simple ].
  602.   Simple      = Term { "+" | OR Term }.
  603.   Relation    = "=" | "#" | "<" | ">".
  604.   Term        = Factor { AND Factor }.
  605.   Factor      = "(" Expression ")".
  606.               | String
  607.               | NOT Factor
  608.               | DEFINED name
  609.               | name.
  610.   String      = "'" { character } "'"
  611.               | '"' { character } '"'.
  612.  
  613.  An operand in an expression is either string or equation name or option name. 
  614.  In the case of equation, the value of equation is used. In the case of option, 
  615.  a string "TRUE" or "FALSE" is used. The operator "+" denotes string 
  616.  concatenation. Relation operators perform string comparison. The NOT operator 
  617.  can be applied to any string with value "TRUE" or "FALSE". The DEFINED 
  618.  operator yields "TRUE" if an option or equation name is declared and "FALSE" 
  619.  otherwise. 
  620.  Example of project file 
  621.  
  622.   % check project mode
  623.   !if not defined mode then
  624.     % by default use debug mode
  625.     !new mode = debug
  626.   !end
  627.   % report the project mode
  628.   !message "Making project in the " + mode + "mode"
  629.   % set options according to the mode
  630.   !if mode = debug then
  631.      - gendebug+
  632.      - checkrange+
  633.   !else
  634.      - gendebug-
  635.   !fi
  636.   % specify template file
  637.   - template = $!/templates/xds.tem
  638.   !module Main.ob2
  639.  
  640.  
  641. ΓòÉΓòÉΓòÉ 4.10. Customize XDS messages ΓòÉΓòÉΓòÉ
  642.  
  643. The file xc.msgcontains texts of error messages in the form 
  644.  
  645. <number>       <text>
  646.  
  647. The following is an extract from xc.msg: 
  648.  
  649. 001 illegal character
  650. 002 comment not closed; started at line %d
  651. ...
  652. 042 incompatible assignment
  653. ...
  654.  
  655. Some messages contain format specifiers for additional arguments. I.e. the 
  656. above message comment not closed contains %d specifier to print a line number. 
  657.  
  658. To use a language other than English for compiler messages it is necessary to 
  659. translate the text of the messages, whilst preserving the error numbers and the 
  660. number and order of format specifiers. 
  661.  
  662.  
  663. ΓòÉΓòÉΓòÉ 4.11. XDS and your C compiler ΓòÉΓòÉΓòÉ
  664.  
  665. XDS allows the C libraries to be used in your projects. Different C compilers 
  666. use different alignment, naming and calling conventions. Thus it is necessary 
  667. to configure XDS for your C compiler in order to use C libraries and modules in 
  668. your program. See Chapter Configuring XDS for a C Compiler for more details. 
  669.  
  670.  
  671. ΓòÉΓòÉΓòÉ 5. Getting Started ΓòÉΓòÉΓòÉ
  672.  
  673. In this and following chapters we assume that XDS is properly installed and 
  674. configured (See Chapter Configuring XDS); the default file extensions are used. 
  675.  
  676. Your XDS package contains two script files, xdswork and xdssamp, which may be 
  677. used to prepare a working directory and a directory for trying the sample 
  678. programs, respectively. For more information, consult your readme.1st file from 
  679. the XDS on-line documentation. 
  680.  
  681.      Using the Modula-2 compiler 
  682.      Using the Oberon-2 compiler 
  683.      Error reporting 
  684.      Running a program 
  685.      Debugging a program 
  686.      Optimizing a program 
  687.  
  688.  
  689. ΓòÉΓòÉΓòÉ 5.1. Using the Modula-2 compiler ΓòÉΓòÉΓòÉ
  690.  
  691. In the working directory, use a text editor to create a file called hello.mod, 
  692. containing the following text: 
  693.  
  694. MODULE hello;
  695.  
  696. IMPORT InOut;
  697.  
  698. BEGIN
  699.  InOut.WriteString("Hello World");
  700.  InOut.WriteLn;
  701. END hello.
  702.  
  703. Type 
  704.  
  705.  xc hello.mod 
  706.  
  707. xc will know that the Modula-2 compiler should be invoked for the source file 
  708. with the extension .mod. The compiler heading line will appear: 
  709.  
  710. Modula-2 version [code generator] "hello.mod"
  711.  
  712. showing which compiler has been invoked (including its version number), which 
  713. code generator is being used (in square brackets) and its version, and finally 
  714. the name of the source file it has been asked to compile. 
  715.  
  716. Assuming that you have correctly typed the source file, after compilation, the 
  717. compiler displays 
  718.  
  719. errors: 0(0)  lines: 15  time: 1.09
  720.  
  721. showing the number of errors, the number of source lines and compilation time. 
  722.  
  723. Note: The XDS compiler reports are user configurable. If the statements above 
  724. do not appear, check that the DECOR equation value contains `c' (compiler 
  725. heading) and `r' (report) letters. 
  726.  
  727.  
  728. ΓòÉΓòÉΓòÉ 5.2. Using the Oberon-2 compiler ΓòÉΓòÉΓòÉ
  729.  
  730. In our bilingual system the Modula-2 source code just shown is also perfectly 
  731. valid as the Oberon-2 code. XDS allows you to use Modula-2 libraries when 
  732. programming in Oberon-2 (in our case InOut library). 
  733.  
  734. As in Modula-2, this source code in Oberon-2 constitutes a top-level module or 
  735. program module. Unlike Modula-2, there is no syntactic distinction between a 
  736. top-level module and any other service module. Oberon-2 compiler must be 
  737. specifically told that this is a program module by using the option MAIN. Copy 
  738. the source file to the file hello.ob2 and type: 
  739.  
  740.  xc hello.ob2 +MAIN 
  741.  
  742. The same sequence of reports will occur as that of the Modula-2 compiler, but 
  743. the Oberon-2 compiler will also report whether a new symbol file was generated 
  744. or not. It is possible to override the default source file extension using M2 
  745. and O2 options: 
  746.  
  747.  xc hello.mod +O2 +MAIN 
  748.  
  749. In this case, the Oberon-2 compiler will be invoked regardless of the file 
  750. extension. 
  751.  
  752.  
  753. ΓòÉΓòÉΓòÉ 5.3. Error reporting ΓòÉΓòÉΓòÉ
  754.  
  755. If either compiler detects an error in your code, an error description will be 
  756. displayed. In most cases a copy of the source line will also be shown with a 
  757. dollar sign "$" placed directly before the point at which the error occurred. 
  758. The format by which XDS reports errors is user configurable (See Error message 
  759. format specification), by default it includes the file name, the line number 
  760. and column in which the error occurred and an error kind, which can be [E]rror, 
  761. [W]arning or [F]ault. 
  762. Example 
  763.  
  764. (hello.m 6,33) [E] expected symbol  ")"
  765.  InOut.WriteString("Hello World"$;
  766. (hello.m 7,2) [E] expected symbol  ";"
  767.  $InOut.WriteLn;
  768.  
  769.  
  770. ΓòÉΓòÉΓòÉ 5.4. Running a program ΓòÉΓòÉΓòÉ
  771.  
  772. After compilation of all modules composing your project you have to link the 
  773. program. The xdsuser script creates the xl script that can be used to link a 
  774. simple program. 
  775.  
  776.    xl hello
  777.  
  778. If your project contains more than one module, we recommend to write a project 
  779. file (See Project files) and use appropriate template file (See Template 
  780. files). The following project file contains all necessary settings: 
  781.  
  782. % debug ON
  783. -gendebug+
  784. -genhistory+
  785. -lineno+
  786. % specify template file
  787. -template = xds.tem
  788. % specify a name of a linker response file
  789. -mkfname = tmp
  790. -mkfext  = mkf
  791. % force generation of the response file
  792. -makefile+
  793. % linker command line
  794. -link = "xlink @%s",mkfname#mkfext;
  795. % main module of the program
  796. !module hello.mod
  797.  
  798. It specifies the template file to use (xds.tem), the name of the linker 
  799. response file (tmp.mkf) and linker command line. 
  800.  
  801. After successful compilation of the whole project the compiler creates the 
  802. linker response file and then executes the command line, specied by the LINK 
  803. equation. 
  804.  
  805. The xds.tem template file defines a template for a linker response file. See 
  806. Template files for the full description of template files. See also the project 
  807. files, generated by the xdsuser script. 
  808.  
  809.  
  810. ΓòÉΓòÉΓòÉ 5.5. Debugging a program ΓòÉΓòÉΓòÉ
  811.  
  812. XDS compilers generate debug information in the CodeView format and allows one 
  813. to use any debugger compatible with this format . However, the postmorten 
  814. historyfeature of XDS run-time support may be used in many cases instead of 
  815. debugger. To enable this feature the option LINENO should be set for all 
  816. modules in the program and the option GENHISTORY for the main module of the 
  817. program; the linker (link386) should be called with the /debug option. 
  818.  
  819. If your program is compiled in this mode, the run-time system will print a 
  820. stack of procedure calls (a file name and a line number) on abnormal 
  821. termination of your program. 
  822. Example 
  823.  
  824. MODULE test;
  825.  
  826. PROCEDURE Div(a,b: INTEGER): INTEGER;
  827. BEGIN
  828.   RETURN a DIV b
  829. END Div;
  830.  
  831. PROCEDURE Try;
  832.   VAR res: INTEGER;
  833. BEGIN
  834.   res:=Div(1,0);
  835. END Try;
  836.  
  837. BEGIN
  838.   Try;
  839. END test.
  840.  
  841. When this program is running, the exception is raised and the run-time system 
  842. prints the exception location and a stack of procedure calls. [3] 
  843.  
  844. #RTS: No exception handler #6: zero or negative divisor
  845. ------------------------------------------------------------
  846. Source file                        LINE  OFFSET  PROCEDURE
  847. ------------------------------------------------------------
  848. "test.mod"                            5 0000000D
  849. "test.mod"                           11 00000024
  850. "test.mod"                           15 00000051
  851.  
  852. The exception was raised in line 5 of test.mod, the Div procedure was called 
  853. from line 11, while the Try procedure was called from line 15 (module body). 
  854.  
  855. In some cases, the history may contain wrong lines. See History for further 
  856. details. 
  857.  
  858.  
  859. ΓòÉΓòÉΓòÉ 5.6. Optimizing a program ΓòÉΓòÉΓòÉ
  860.  
  861. Unlike many other compilers, XDS always produces optimized code. There are no 
  862. such things in XDS as levels or different types of optimization except the 
  863. instruction shedulingIntroduced in version 2.14 which can be turned on or off 
  864. using the DOREORDER option. It is sometimes happened with almost all compilers 
  865. that unoptimized version of the program works properly, but optimized one does 
  866. not. If a compiler have a dozen of optimization options it may be extremely 
  867. difficult to debug the compiler itself. A compiler manufacturer has to check 
  868. all possible combinations of options. It is not the case with XDS. The only 
  869. option that may implicitly disable some of optimizations is the GENDEBUG 
  870. option. 
  871.  
  872. There are still several ways to control the generated code. First of all you 
  873. have to choose what is more important for you: fast code or small code. By 
  874. default, the option SPACE is set off, forcing the compiler to favor the fast 
  875. code. 
  876.  
  877. To get the maximum performance do the following: 
  878.  
  879.      turn SPACE off 
  880.  
  881.      turn GENDEBUG off 
  882.  
  883.      turn ALIGNMENT on 
  884.  
  885.      turn DOREORDER on 
  886.  
  887.      turn ??? off if you intend to run your code mostly on Pentium-based 
  888.       computers 
  889.  
  890.      turn run-time checks and overflow checks off 
  891.  
  892.  It is possible not to turn run-time checks off in the product versions of your 
  893.  programs, because the code generator usually removes redundant checks. An 
  894.  average program with all run-time checks turned off runs only 10-15% faster 
  895.  (the code size is usually significantly smaller). 
  896.  
  897.  Two options should be used with care: 
  898.  
  899.      the PROCINLINE option allows the compiler to expand procedures in-line. 
  900.       As a rule switching the option ON leads to faster but bigger code. 
  901.       However, the effect of this option depends on your programming style 
  902.       (size of procedures, etc). 
  903.  
  904.      the NOPTRALIAS option allows the compiler to assume that there is no 
  905.       pointer aliasing, i.e. there are no pointers bounded to non-structure 
  906.       variables. The code quality is better if the option is ON. 
  907.  
  908.  Example of project file for maximum performance 
  909.  
  910.   -alignment+          % is unnecessary under Linux
  911.   -noptralias+
  912.   -procinline+
  913.   -space
  914.   -doreorder+
  915.   -cpu486
  916.  
  917.   -checkindex
  918.   -checkrange
  919.   -checknil
  920.   -ioverflow
  921.   -coverflow
  922.   -gendebug
  923.   -genhistory
  924.   -lineno
  925.   !module Foo.mod
  926.  
  927.  In some cases, it may be better to set different options for different modules 
  928.  in your program. See dry.mod from XDS samples. 
  929.  
  930.  
  931. ΓòÉΓòÉΓòÉ 6. Using XDS ΓòÉΓòÉΓòÉ
  932.  
  933.      Invoking XDS 
  934.      XDS operation modes 
  935.      Files generated during compilation 
  936.      Project files 
  937.      Make strategy 
  938.      Smart recompilation 
  939.      Template files 
  940.  
  941.  
  942. ΓòÉΓòÉΓòÉ 6.1. Invoking XDS ΓòÉΓòÉΓòÉ
  943.  
  944. The XDS Modula-2 and Oberon-2 compilers are combined together with additional 
  945. operation modes into a single utility, xc. When invoked without parameters, the 
  946. utility outputs the help information. 
  947.  
  948. xc is invoked from the command line of the following form 
  949.  
  950.  xc { OPERATION MODE | OPTION | NAME } 
  951.  
  952. where NAME for different operation modes is a module name, file name or a 
  953. project name. See XDS operation modes for the full description of operation 
  954. modes. 
  955.  
  956. OPTION is a compiler setup directive (See Options). On the command line all 
  957. options are applied to all operands. On some platforms it may be necessary to 
  958. enclose some setup directive in quotation marks, e.g. `enable option' directive 
  959. under MacOS/MPW shell: 
  960.  
  961.  xc hello.mod '-checkindex+' 
  962.  
  963. See Chapter Compiler Options and Equations for the list of all compiler options 
  964. and equations. 
  965.  
  966.      Precedence of compiler options 
  967.  
  968.  
  969. ΓòÉΓòÉΓòÉ 6.1.1. Precedence of compiler options ΓòÉΓòÉΓòÉ
  970.  
  971. The xc utility can receive its options from the 
  972.  
  973.    1. configuration file xc.cfg (See Configuration file) 
  974.  
  975.    2. command line (See XDS operation modes) 
  976.  
  977.    3. project file (if present) (See Project files) 
  978.  
  979.    4. inline in a source text (not all options can be used there) (See Source 
  980.       code directives) 
  981.  
  982.  At any point during operation, the last value of an option will be in effect. 
  983.  Thus, if the equation OBERON was set to .ob2 in the configuration file, but 
  984.  then set to .o2 on the command line, then XDS will recognize .o2 as the 
  985.  default Oberon-2 extension. 
  986.  
  987.  
  988. ΓòÉΓòÉΓòÉ 6.2. XDS operation modes ΓòÉΓòÉΓòÉ
  989.  
  990. XDS has the following operation modes: 
  991.  
  992. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  993.  Mode     Meaning
  994.  
  995.  COMPILE  Compile all modules given on the command line
  996.  
  997.  PROJECT  Make all projects given on the command line
  998.  
  999.  MAKE     Check dependencies and recompile
  1000.  
  1001.  GEN      Generate makefile for all projects
  1002.  
  1003.  BROWSE   Extract definitions from symbol files
  1004.  
  1005.  HELP     Print help and abort the program
  1006. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1007.  
  1008. Both the PROJECT and MAKE modes have two optional operation submodes: BATCH and 
  1009. ALL. Two auxilary operation submodes - OPTIONS and EQUATIONS can be used to 
  1010. inspect the set of compiler options and equations and their values. 
  1011.  
  1012. From the command line, the compiler mode is set with '=' followed by the 
  1013. required mode. Only the unique portion of a name may be specified. Operation 
  1014. mode names are not case sensitive, thus 
  1015.  
  1016.         =PROJECT   is equivalent to   =p
  1017.         =BROWSE    is equivalent to   =Bro
  1018.  
  1019. Operation modes and options can be placed everywhere in the command line. Thus 
  1020. two following invokations are equal to each other: 
  1021.  
  1022.  xc =make hello.mod =all -checknil+ 
  1023. xc -checknil+ =a =make hello.mod 
  1024.  
  1025.      COMPILE mode 
  1026.      MAKE mode 
  1027.      PROJECT mode 
  1028.      GEN mode 
  1029.      BROWSE mode 
  1030.      ALL submode 
  1031.      BATCH submode 
  1032.      OPTIONS submode 
  1033.      EQUATIONS submode 
  1034.  
  1035.  
  1036. ΓòÉΓòÉΓòÉ 6.2.1. COMPILE mode ΓòÉΓòÉΓòÉ
  1037.  
  1038.  xc [=compile] { FILENAME | OPTION } 
  1039.  
  1040. COMPILE is the default mode, and can be invoked simply by supplying xc with a 
  1041. source module(s) to compile. If xc is invoked without a given mode, COMPILE 
  1042. mode is assumed. In order to determine which compiler should be used, xc looks 
  1043. at the extensions of the given source files. The default mapping of extensions 
  1044. is given below : 
  1045.  
  1046. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1047.  .mod  - Modula-2 implementation module
  1048.  
  1049.  .def  - Modula-2 definition module
  1050.  
  1051.  .ob2  - Oberon-2 module
  1052. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1053.  
  1054. For example: 
  1055.  
  1056.  xc hello.mod 
  1057.  
  1058. will invoke the Modula-2 compiler, whilst: 
  1059.  
  1060.  xc hello.ob2 
  1061.  
  1062. will invoke the Oberon-2 compiler. 
  1063.  
  1064. The user is able to reconfigure the extension mapping (See Filename 
  1065. extensions). It is also possible to override this extension mapping from the 
  1066. command line using options M2 and O2 (See Options): 
  1067.  
  1068.  xc hello.mod +o2 (* invokes O2 compiler *) 
  1069. xc hello.ob2 +m2 (* invokes M2 compiler *) 
  1070.  
  1071. Note: If the rest of this manual, the COMPILE mode also refers to any case in 
  1072. which the compiler compiles a source file, regardless of the invokation mode 
  1073. (COMPILE, MAKE, or PROJECT). For instance, an option or equation, which is 
  1074. stated to affect the compiler behaviour in the COMPILE mode, is relevant to 
  1075. MAKE and PROJECT modes as well. 
  1076.  
  1077.  
  1078. ΓòÉΓòÉΓòÉ 6.2.2. MAKE mode ΓòÉΓòÉΓòÉ
  1079.  
  1080.  xc =make [=batch] [=all] { FILENAME | OPTION } 
  1081.  
  1082. In the MAKE mode the compiler calculates module dependencies (using IMPORT 
  1083. clauses) and then recompiles all necessary modules. Starting from the files on 
  1084. the command line, it tries to find an Oberon module or a definition and 
  1085. implementaion module for each imported module. It then does the same for each 
  1086. of the imported modules until all modules are located. Note that a search is 
  1087. made for source files only. If a source file is not found, the imported modules 
  1088. will not be appended to the recompile list. See section Make strategy for more 
  1089. details. 
  1090.  
  1091. When all modules are gathered, XDS performs an action according to the 
  1092. operation submode. If the BATCH submode is specified, XDS creates a batch file 
  1093. of all necessary compilations, rather than actually calling the compilers and 
  1094. compiling the source code (See BATCH submode). 
  1095.  
  1096. If the ALL submode is specified, all gathered files are recompiled, otherwise 
  1097. XDS calculates conditions for recompilation and recompiles only those files 
  1098. that are necessary. The smart recompilation algorithm is described in Smart 
  1099. recompilation. 
  1100.  
  1101. Usually, only a Modula-2 program module or an Oberon-2 top-level module should 
  1102. be specified on the command line. If the LINK equation is set in either 
  1103. configuration file or xc command line, the linker will then be called 
  1104. automatically in case of successful recompilation. This feature allows you to 
  1105. build simple programs without necessity to create a project file. 
  1106.  
  1107.  
  1108. ΓòÉΓòÉΓòÉ 6.2.3. PROJECT mode ΓòÉΓòÉΓòÉ
  1109.  
  1110.  xc =project [=batch] [=all] { PROJECTFILE | OPTION } 
  1111.  
  1112. The PROJECT mode is essentially the same as the MAKE mode except that the 
  1113. modules to be `made' are provided in a project file. A project file specifies a 
  1114. set of options and a list of modules. See Project files for further details. As 
  1115. in the MAKE mode, ALL and BATCH submodes can be used. 
  1116.  
  1117. If a file extension of a project file is omitted, XDS will use an extension 
  1118. given by the equation PRJEXT (.prj by default). 
  1119.  
  1120. It may be desirable to compile a single module in the environment specified in 
  1121. the project file. It can be done with the PRJ equation in the COMPILE operation 
  1122. mode. 
  1123.  
  1124.  xc -prj=myproject MyModule.mod 
  1125.  
  1126.  See also 
  1127.  
  1128.      MAKE operation mode: MAKE mode 
  1129.  
  1130.      Make strategy: Make strategy 
  1131.  
  1132.      Smart recompilation: Smart recompilation 
  1133.  
  1134.  
  1135. ΓòÉΓòÉΓòÉ 6.2.4. GEN mode ΓòÉΓòÉΓòÉ
  1136.  
  1137.  xc =gen { PROJECTFILE | OPTION } 
  1138.  
  1139. The GEN operation mode allows one to generate a file containing information 
  1140. about your project. The most important usage is to generate a linker response 
  1141. file (See Running a program). 
  1142.  
  1143. This operation mode can also be used to obtain an additional information about 
  1144. your project, e.g. a list of all modules, import lists, etc. 
  1145.  
  1146. A so-called template file is used in this mode. A template file name is 
  1147. determined by the TEMPLATE equation.A template file is a text file, some lines 
  1148. of which are marked with an assigned symbol. All the lines which are not marked 
  1149. are copied to output. The marked lines are processed in a special way (See 
  1150. Template files). 
  1151.  
  1152. XDS will create a file with a name determined by either the compiler option 
  1153. MKFNAME or the project file name. A file name is then concatenated with the 
  1154. extension specified by the equation MKFEXT. 
  1155.  
  1156.  
  1157. ΓòÉΓòÉΓòÉ 6.2.5. BROWSE mode ΓòÉΓòÉΓòÉ
  1158.  
  1159.  xc =browse { MODULENAME | OPTION } 
  1160.  
  1161. The BROWSE operation mode allows one to generate a pseudo definition module for 
  1162. an Oberon-2 module. In this mode XDS scans the symbol file and produces a 
  1163. Modula-2-like definition module which contains all client-visible objects. 
  1164.  
  1165. The configuration option BSDEF (See Equations) specifies the extension of a 
  1166. generated file. If this option is not set, then the default extension (.odf) 
  1167. will be used. 
  1168.  
  1169. Options BSCLOSURE and BSREDEFINE can be used to control the form of a generated 
  1170. file. Note: the BSTYLE equation (described in Creating a definition) is ignored 
  1171. in this operation mode, and the browse style is always set to DEF. 
  1172.  
  1173. The MAKEDEF option (See Creating a definition) provides an alternative method 
  1174. of producing pseudo definition modules, preserving so-called exported comments 
  1175. if necessary. 
  1176.  
  1177.  
  1178. ΓòÉΓòÉΓòÉ 6.2.6. ALL submode ΓòÉΓòÉΓòÉ
  1179.  
  1180. In both PROJECT and MAKE modes, XDS checks the time stamps of the files 
  1181. concerned and recompiles only those files that are necessary. If ALL submode is 
  1182. set, the time stamps are ignored, and all files are compiled. 
  1183.  
  1184.  
  1185. ΓòÉΓòÉΓòÉ 6.2.7. BATCH submode ΓòÉΓòÉΓòÉ
  1186.  
  1187. In the BATCH submode, XDS creates a batch file of all necessary compilation, 
  1188. rather than actually calling the compilers and compiling the source code. 
  1189.  
  1190. A batch file is sequence of lines beginning with the compiler name, followed by 
  1191. module names to recompile. 
  1192.  
  1193. XDS will create a batch file with a name determined by either: 
  1194.  
  1195.    1. The compiler option BATNAME (see Equations) 
  1196.  
  1197.    2. The project file name (if given) 
  1198.  
  1199.    3. The name out (if no name can be determined by above). 
  1200.  
  1201.  Batch file name is then concatenated with the batch file extension specified 
  1202.  by the equation BATEXT (.bat by default). 
  1203.  
  1204.   See also 
  1205.  
  1206.      option LONGNAME (Options) 
  1207.  
  1208.      equation BATWIDTH (Equations) 
  1209.  
  1210.  
  1211. ΓòÉΓòÉΓòÉ 6.2.8. OPTIONS submode ΓòÉΓòÉΓòÉ
  1212.  
  1213. The OPTIONS submode allows you to inspect the values of options which are set 
  1214. in the configuration file, project file and on the command line. It can be used 
  1215. together with COMPILE, MAKE and PROJECT modes. 
  1216.  
  1217. The following invocation will print (to the standard output) the list of all 
  1218. defined options, including all pre-declared options, all options declared in 
  1219. the configuration file, in the project file my.prj and on the command line (xyz 
  1220. option): 
  1221.  
  1222.  xc =options -prj=my.prj -xyz:+ 
  1223.  
  1224. In the PROJECT mode options are listed for each project file given on the 
  1225. command line. 
  1226.  
  1227.  
  1228. ΓòÉΓòÉΓòÉ 6.2.9. EQUATIONS submode ΓòÉΓòÉΓòÉ
  1229.  
  1230. The EQUATIONS submode allows you to inspect the values of options which are set 
  1231. in the configuration file, project file and on the command line. It can be used 
  1232. together with COMPILE, MAKE and PROJECT modes. 
  1233.  
  1234.  
  1235. ΓòÉΓòÉΓòÉ 6.3. Files generated during compilation ΓòÉΓòÉΓòÉ
  1236.  
  1237. When applied to a file which contains a module name, the compilers produce the 
  1238. following files. 
  1239.  
  1240.  
  1241. ΓòÉΓòÉΓòÉ 6.4. Project files ΓòÉΓòÉΓòÉ
  1242.  
  1243. A project file has the following structure: 
  1244.  
  1245.      {OPTION}
  1246.      {!module {FILENAME}}
  1247.  
  1248. where OPTIONs are the compiler setup directives (See Options), defining options 
  1249. and equations that all modules should be compiled with, and FILENAMEs are 
  1250. modules of the project. It should be noted that XDS recursively looks at all 
  1251. the given files for any imported modules. Thus, usually, a project file would 
  1252. consist of one single module, the main program module. At least one module 
  1253. should be specified in a project file. 
  1254.  
  1255. Every line in a project file can contain only one setup directive. A character 
  1256. "%" is the comment character. It causes the rest of the line to be discarded. 
  1257. Note: the comment character can not be used in setting an equation. 
  1258.  
  1259. XDS gives you complete freedom where to set options, equations and redirection 
  1260. directives. However, it is advisable to specify only those settings in the 
  1261. configuration and redirection files which are applied to all your projects, and 
  1262. use project files to specify all project-dependent options and redirection 
  1263. directive. 
  1264.  
  1265. A project file can contain several LOOKUP equations, which allows one to 
  1266. redefine some search paths. 
  1267. Example Project File: 
  1268.  
  1269. -mod = mod
  1270. -checkindex+
  1271. -lookup = *.mod = mod
  1272. -lookup = *.sym = sym; /xds/sym
  1273. !module hello
  1274.  
  1275. In the above example, XDS will search files with .mod and .sym extensions using 
  1276. search paths specified in the project file. For all other extensions, search 
  1277. paths, specified in the redirection file or configuration file or on the 
  1278. command line will be used. 
  1279.  
  1280. A project file is specified explicitly in the PROJECT and GEN operation modes. 
  1281. In these cases all options and equations are set and then XDS proceeds the 
  1282. module list to gather all modules constituting a project (See Make strategy). 
  1283.  
  1284. In the MAKE and COMPILE operation mode, a project file can be specified using 
  1285. the PRJ equation. In these cases the module list is ignored, but all options 
  1286. and equations are set. 
  1287.  
  1288. The following command line forces XDS to compile the module hello.mod in the 
  1289. COMPILE operation mode using options and equations specified in the project 
  1290. file hello.prj: 
  1291.  
  1292.  xc hello.mod -prj=hello.prj 
  1293.  
  1294.  
  1295. ΓòÉΓòÉΓòÉ 6.5. Make strategy ΓòÉΓòÉΓòÉ
  1296.  
  1297. All information presented here concerns MAKE, PROJECT and GEN operation modes. 
  1298. In these modes XDS builds a set of all modules that constitute the project, 
  1299. starting from the modules specified in a project file (PROJECT and GEN) or on a 
  1300. command line (MAKE). 
  1301.  
  1302. The MAKE mode will be used in most of the following examples, but the comments 
  1303. will concern both to the PROJECT and GEN modes. 
  1304.  
  1305. At first, XDS tries to find all given modules according to the following 
  1306. strategy: 
  1307.  
  1308.      If both a filename extension and a path to the a file are specified, it 
  1309.       checks if the given file exists. 
  1310.  
  1311.        xc =make mod\hello.mod 
  1312.  
  1313.      If a filename extension is specified, the file will try to find a file 
  1314.       using search paths. 
  1315.  
  1316.        xc =make hello.mod 
  1317.  
  1318.     
  1319.  
  1320.       If a filename extension is not specified, XDS will try to find a file 
  1321.       with the Oberon-2 extension, Modula-2 module and definition extensions. 
  1322.  
  1323.        xc =make hello 
  1324.  
  1325.       An error will be raised if there is more than one source file, e.g. both 
  1326.       hello.ob2 and hello.mod files are accessible. 
  1327.  
  1328.  Starting from the given files XDS tries to find an Oberon module or a pair - a 
  1329.  definition and implementation module for each imported module. It then tries 
  1330.  to do the same for each of the imported modules until all modules are located. 
  1331.  For all modules XDS checks the correspondence between the file name extensions 
  1332.  and a kind of the module. 
  1333.  
  1334.  
  1335. ΓòÉΓòÉΓòÉ 6.6. Smart recompilation ΓòÉΓòÉΓòÉ
  1336.  
  1337. In the PROJECT and MAKE mode, XDS offers smart recompilation of all modules in 
  1338. a project which are inconsistent with the available source code files. XDS uses 
  1339. a file modification time to determine which file has been changed. For every 
  1340. module the decision is made (to recompile or not) only after the decision is 
  1341. made for all modules on which it depends. A file is compiled if one or more of 
  1342. the following conditions is true: 
  1343.  
  1344.  definition module 
  1345.  
  1346.                the symbol file is missing 
  1347.  
  1348.                the symbol file is present but the modification date is earlier 
  1349.                 than that of the source file or one of the imported symbol 
  1350.                 files 
  1351.  
  1352.  implementation module 
  1353.  
  1354.                the code file is missing 
  1355.  
  1356.                the code file is present but the file modification date is 
  1357.                 earlier than that of the source file or one of the imported 
  1358.                 symbol files (including its own symbol file) 
  1359.  
  1360.  program module 
  1361.  
  1362.                the code file is missing 
  1363.  
  1364.                the code file is present but the file modification date is 
  1365.                 earlier than that of the source file or one of the imported 
  1366.                 symbol files 
  1367.  
  1368.  Oberon-2 module 
  1369.  
  1370.                the symbol file is missing 
  1371.  
  1372.                the symbol file is present but the modification date is earlier 
  1373.                 than that of one of the imported symbol files 
  1374.  
  1375.                the code file is missing 
  1376.  
  1377.                the code file is present but the file modification date is 
  1378.                 earlier than that of the source file or one of the imported 
  1379.                 symbol files 
  1380.  
  1381.  When the VERBOSE option is ON, XDS reports why the module is recompiled. Note: 
  1382.  if an error occurs when a definition or Oberon-2 module is compiled, all 
  1383.  client modules will not be compiled at all. 
  1384.  
  1385.  
  1386. ΓòÉΓòÉΓòÉ 6.7. Template files ΓòÉΓòÉΓòÉ
  1387.  
  1388. A template file is used for defining the structure of the file generated in the 
  1389. GEN operation mode or PROJECT mode, if the option MAKEFILE is ON. XDS copies 
  1390. lines from the template file into the output file verbatim, unless the lines 
  1391. are marked as requiring further attention. A single character (attention mark) 
  1392. is specified by the equation ATTENTION(default is '!'). 
  1393.  
  1394. A marked line (or template) has the following format The same syntax is used in 
  1395. the LINK equation. : 
  1396.  
  1397. Template  = { Sentence }.
  1398. Sentence  = Item { "," Item } ";" | Iterator.
  1399. Item      = Atom | [ Atom | "^" ] "#" [ Extension ].
  1400. Atom      = String | name.
  1401. String    = '"' { character } '"'
  1402.           | "'" { character } "'".
  1403. Extension = [ ">" ] Atom.
  1404. Iterator  = "{" Set ":" { Sentence } "}".
  1405. Set       = { Keyword | String }
  1406. Keyword   = DEF | IMP | OBERON | MAIN
  1407.           | C | HEADER | ASM | OBJ.
  1408.  
  1409. A name should be the name of equation. Not more than three items may be used in 
  1410. a sentence. A first item in a sentence is a format string, while others are 
  1411. arguments. 
  1412.  
  1413. In the simplest form a template file can be used to output a value of an 
  1414. equation. For example, if a template file contains the line 
  1415.  
  1416. ! "Current project is %s.\n",prj;
  1417.  
  1418. and the project prj\test.prj is processed, the output will contain the line 
  1419.  
  1420. Current project is prj/test.prj.
  1421.  
  1422. Note: the following line 
  1423.  
  1424. ! prj;
  1425.  
  1426. is valid, but will produce unexpected result under MS-DOS or Windows: 
  1427.  
  1428. prj     est.prj
  1429.  
  1430. because \t in the format string will be replaced by tabulator character. Use 
  1431. the following form instead: 
  1432.  
  1433. ! "%s",prj;
  1434.  
  1435. The "#" operator creates a file name from the namegiven by either equation 
  1436. value or literal string and extension. A file names is build according to XDS 
  1437. search paths. For example, if a path to the XDS library directory is defined: 
  1438.  
  1439. *.lib = /xds/lib
  1440.  
  1441. the line 
  1442.  
  1443. ! "libxds"#"lib"
  1444.  
  1445. will produce 
  1446.  
  1447. /xds/lib/libxds.lib
  1448.  
  1449. If the modifier ">" is specified, XDS assumes that the file with this name is 
  1450. output file and builds its name according to the strategy for output files (See 
  1451. Redirection file). The form in which a name or extension is omitted can be used 
  1452. in an iterator only. 
  1453.  
  1454. Iterators are used to generate a text for all modules from the specified set. 
  1455. Sentences inside the first level brackets are repeated for all modules of the 
  1456. project, while sentences inside the second level are repeated for all imported 
  1457. modules. A set is a sequence of keywords and strings. Each string denotes a 
  1458. specific module, while a keyword denotes all modules of specific kind. The 
  1459. meaning of keywords is the following: 
  1460.  
  1461. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1462.  Keyword  Meaning
  1463.  
  1464.  DEF      Modula-2 definition module
  1465.  
  1466.  IMP      Modula-2 implementation module
  1467.  
  1468.  MAIN     Modula-2 program module or Oberon module, marked as MAIN
  1469.  
  1470.  OBERON   Oberon module
  1471.  
  1472.  C        C source text
  1473.  
  1474.  HEADER   C header file
  1475.  
  1476.  ASM      assembler source text
  1477.  
  1478.  OBJ      object file
  1479. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1480.  
  1481. The following template file can be used for listing all modules in the project 
  1482. for which source files are available: 
  1483.  
  1484. ! { imp oberon main: "%s ",#; }
  1485.  
  1486. For example, consider a program module A, which imports modules B and C. B 
  1487. itself imports D. All modules are written in Modula-2. 
  1488.  
  1489.             A
  1490.           /   \
  1491.          B     C
  1492.          |
  1493.          D
  1494.  
  1495. The template given above would generate the following line: 
  1496.  
  1497. A.mod B.mod C.mod D.mod
  1498.  
  1499. To output both definition and implementation modules, one can write: 
  1500.  
  1501. ! { def : "%s ",#; }
  1502. ! { imp oberon main: "%s ",#; }
  1503.  
  1504. Then the output will be: 
  1505.  
  1506. B.def C.def D.def A.mod B.mod C.mod D.mod
  1507.  
  1508. The next template file can be used for listing all modules in the project 
  1509. together with their import: 
  1510.  
  1511. ! { imp main: "%s\n",#; { def: "  %s\n",#; } }
  1512.  
  1513. The form ^# may be used in the second level iterator to out a current name of 
  1514. the fisrt level iterator. 
  1515.  
  1516. The XDS distribution contains a template file xds.tem which can be used to 
  1517. produce a linker response file (See Running a program). 
  1518.  
  1519.  
  1520. ΓòÉΓòÉΓòÉ 7. Compiler Options and Equations ΓòÉΓòÉΓòÉ
  1521.  
  1522. A rich set of XDS options allows one to control the source language, code 
  1523. generated and internal limits and settings. We distinguish between boolean 
  1524. options (or just options) and equations. An option can be set ON (TRUE) or OFF 
  1525. (FALSE), while an equation value is a string. 
  1526.  
  1527.      Options 
  1528.      Description of options 
  1529.      Equations 
  1530.      Description of equations 
  1531.      Error message format specification 
  1532.  
  1533.  
  1534. ΓòÉΓòÉΓòÉ 7.1. Options ΓòÉΓòÉΓòÉ
  1535.  
  1536. Options control the process of compilation, including language extensions, 
  1537. run-time checks and code generation. An option can be set ON (TRUE) or OFF 
  1538. (FALSE). 
  1539.  
  1540. A compiler setup directive (See Options) is used to set the option value or to 
  1541. declare it. 
  1542.  
  1543. Options may be set in the configuration file (See Configuration file), on the 
  1544. command line (See XDS operation modes), in the project file (See Project files) 
  1545. or in the source text (See Source code directives). At any point of operation, 
  1546. the last value of an option is in effect. 
  1547.  
  1548. All options are listed in the section Description of options, see also tables 
  1549. Options (page table:opt:check), Options (page table:opt:ext), Options (page 
  1550. table:opt:code) and Options (page table:opt:misc). 
  1551.  
  1552. [htbp] 
  1553.  
  1554. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1555.  Option       Meaning
  1556.  
  1557.  ASSERT       enable ASSERT generation
  1558.  
  1559.  CHECKDINDEX  check of dynamic array bounds
  1560.  
  1561.  CHECKDIV     check for a positive divisor
  1562.  
  1563.               (DIV and MOD)
  1564.  
  1565.  CHECKINDEX   check of static array bounds
  1566.  
  1567.  CHECKNIL     NIL pointer dereference check
  1568.  
  1569.  CHECKPROC    check of a formal procedure call
  1570.  
  1571.  CHECKRANGE   range checks
  1572.  
  1573.               (range types and enumerations)
  1574.  
  1575.  CHECKSET     range check of set operations
  1576.  
  1577.  CHECKTYPE    dynamic type guards (Oberon-2 only)
  1578.  
  1579.  COVERFLOW    cardinal overflow check
  1580.  
  1581.  IOVERFLOW    integer overflow check
  1582. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1583.  
  1584. Run-time checks 
  1585.  
  1586. [htbp] 
  1587.  
  1588. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1589.  Option         Meaning
  1590.  
  1591.  M2ADDTYPES     add SHORT and LONG types
  1592.  
  1593.  M2BASE16       use 16-bits basic types in Modula-2
  1594.  
  1595.  M2CMPSYM       compare symbol files in Modula-2
  1596.  
  1597.  M2EXTENSIONS   enables Modula-2 extensions
  1598.  
  1599.  M2UNPACKTYPES  forces to use unpack form of some types
  1600.  
  1601.  O2EXTENSIONS   enables Oberon-2 extensions
  1602.  
  1603.  O2ISOPRAGMA    enables ISO Modula-2 pragmas in Oberon
  1604.  
  1605.  O2NUMEXT       enables Oberon-2 scientific extensions
  1606.  
  1607.  STORAGE        enables the default memory management in Modula-2
  1608. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1609.  
  1610. Source language control options 
  1611.  
  1612. [htbp] 
  1613.  
  1614. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1615.  Option       Meaning
  1616.  
  1617.  __GEN_C__    ANSI C code generation
  1618.  
  1619.  __GEN_X86__  code generation for 386/486/Pentium
  1620.  
  1621.  ALIGNMENT    align data
  1622.  
  1623.  DEFLIBS      put the default library names into object files
  1624.  
  1625.  DOREORDER    perform instruction scheduling
  1626.  
  1627.  GENCPREF     generate underscore prefixes
  1628.  
  1629.  GENDEBUG     generate code in the debug mode
  1630.  
  1631.  GENFRAME     always generate a procedure frame
  1632.  
  1633.  GENHISTORY   enables postmorten history
  1634.  
  1635.  GENPTRINIT   generate a local pointer initialization
  1636.  
  1637.  LINENO       generate line numbers in object files
  1638.  
  1639.  NOPTRALIAS   ignore the pointer aliasing
  1640.  
  1641.  ONECODESEG   generate one code segment
  1642.  
  1643.  PROCINLINE   enables in-line procedure's expansion
  1644.  
  1645.  SPACE        code size is more important then speed
  1646.  
  1647.  VERSIONKEY   append version key to the module initialization
  1648. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1649.  
  1650. Code generator control options 
  1651.  
  1652. [htbp] 
  1653.  
  1654. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1655.  Option      Meaning
  1656.  
  1657.  BSCLOSURE   browse control option
  1658.  
  1659.  BSREDEFINE  browse control option
  1660.  
  1661.  CHANGESYM   permission to change a symbol file
  1662.  
  1663.  FATFS       limit file names to 8.3
  1664.  
  1665.  GCAUTO      enables implicit call of the garbage collector
  1666.  
  1667.  LONGNAME    use long names in batch files
  1668.  
  1669.  M2          forces the Modula-2 compiler
  1670.  
  1671.  MAIN        marks the Oberon-2 main module
  1672.  
  1673.  MAKEDEF     generate definition
  1674.  
  1675.  MAKEFILE    generate makefile
  1676.  
  1677.  O2          forces the Oberon-2 compiler
  1678.  
  1679.  OVERWRITE   create a file, always overwrites the old one
  1680.  
  1681.  SHOWALIEN   produce warnings on absent modules
  1682.  
  1683.  VERBOSE     produce verbose messages
  1684.  
  1685.  WOFF        suppresse warning messages
  1686.  
  1687.  XCOMMENTS   preserve exported comments
  1688. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  1689.  
  1690. Miscellaneous options 
  1691.  
  1692.  
  1693. ΓòÉΓòÉΓòÉ 7.2. Description of options ΓòÉΓòÉΓòÉ
  1694.  
  1695. This section lists all options in alphabetical order. Those options that may be 
  1696. arbitrarily placed in the source code are marked as inline options (See also 
  1697. Source code directives). There are also options which can be placed in the 
  1698. source file, but only before the module header. These options are marked as 
  1699. header. If an option is not marked either as header or inline, then the result 
  1700. of setting it in the source text is undefined. 
  1701.  
  1702. The operation modes to which an option is significant are listed in square 
  1703. brackets ([]) after the option name; the character '*' stands for all operation 
  1704. modes. For example, [browse] means that the option is used by the compiler in 
  1705. the BROWSE operation mode only. Note: in the MAKE and PROJECT mode the compiler 
  1706. switches to the COMPILE mode to compile a module. 
  1707.  
  1708. Run-time check options are ON by default. If it is not explicitly specified, 
  1709. other options are OFF (FALSE) by default. 
  1710.  
  1711.      __GEN_X86__ - code generation for 386/486/Pentium 
  1712.      __GEN_C__ - ANSI C code generation 
  1713.      ALIGNMENT - align data 
  1714.      ASSERT - enable ASSERT generation 
  1715.      BSCLOSURE - browse control option 
  1716.      BSREDEFINE - browse control option 
  1717.      CHANGESYM - permission to change a symbol file 
  1718.      CHECKDINDEX - check of dynamic array bounds 
  1719.      CHECKDIV - check for a positive divisor (DIV and MOD) 
  1720.      CHECKINDEX - check of static array bounds 
  1721.      CHECKNIL - NIL pointer dereference check 
  1722.      CHECKPROC - check of a formal procedure call 
  1723.      CHECKRANGE - range checks (range types and enumerations) 
  1724.      CHECKSET - range check of set operations 
  1725.      CHECKTYPE - dynamic type guards (Oberon-2 only) 
  1726.      COVERFLOW - cardinal overflow check 
  1727.      DEFLIBS - put the default library names into object files 
  1728.      DOREORDER - perform instruction scheduling 
  1729.      FATFS - limit file names to 8.3 
  1730.      GCAUTO - enables implicit call of the garbage collector 
  1731.      GENCPREF - generate underscore prefixes 
  1732.      GENDEBUG - generate code in the debug mode 
  1733.      GENFRAME - always generate a procedure frame 
  1734.      GENHISTORY - enable postmortem history 
  1735.      GENPTRINIT - generate a local pointer initialization 
  1736.      IOVERFLOW - integer overflow check 
  1737.      LINENO - generate line numbers 
  1738.      LONGNAME - use long names in batch files 
  1739.      M2 - forces the Modula-2 compiler 
  1740.      M2ADDTYPES - add SHORT and LONG types 
  1741.      M2BASE16 - use 16-bits basic types in Modula-2 
  1742.      M2CMPSYM - compare symbol files in Modula-2 
  1743.      M2EXTENSIONS - enables Modula-2 extensions 
  1744.      M2UNPACKTYPES - forces to use unpack form of some types 
  1745.      MAIN - marks the Oberon-2 main module 
  1746.      MAKEDEF - generate definition 
  1747.      MAKEFILE - generate makefile 
  1748.      NOPTRALIAS - ignore the pointer aliasing 
  1749.      O2 - forces the Oberon-2 compiler 
  1750.      O2EXTENSIONS - enables Oberon-2 extensions 
  1751.      O2ISOPRAGMA - enable ISO Modula-2 pragmas in Oberon 
  1752.      O2NUMEXT - enable Oberon-2 scientific extension 
  1753.      ONECODESEG - generate one code segment 
  1754.      OVERWRITE - create a file, always overwrites the old one 
  1755.      PROCINLINE - enables in-line procedure's expansion 
  1756.      SHOWALIEN - produce warnings on absent modules 
  1757.      SPACE - code size is more important then speed 
  1758.      STORAGE - enables the default memory management in Modula-2 
  1759.      VERBOSE - produce verbose messages 
  1760.      VERSIONKEY - append version key to the module initialization 
  1761.      WOFF - suppresse warning messages 
  1762.      XCOMMENTS - preserve exported comments 
  1763.  
  1764.  
  1765. ΓòÉΓòÉΓòÉ 7.2.1. __GEN_X86__ - code generation for 386/486/Pentium ΓòÉΓòÉΓòÉ
  1766.  
  1767. Modes: COMPILE 
  1768.  
  1769. The compiler sets this option ON, if the code generation for 386/486/Pentium is 
  1770. in operation. 
  1771.  
  1772. The option can be used for compiling different text fragments for different 
  1773. targets. See also Conditional compilation. 
  1774.  
  1775.  
  1776. ΓòÉΓòÉΓòÉ 7.2.2. __GEN_C__ - ANSI C code generation ΓòÉΓòÉΓòÉ
  1777.  
  1778. Modes: COMPILE 
  1779.  
  1780. The compiler sets this option ON, if the C code generation is in operation. 
  1781.  
  1782. The option can be used for compiling different text fragments for different 
  1783. targets. See also Conditional compilation. 
  1784.  
  1785.  
  1786. ΓòÉΓòÉΓòÉ 7.2.3. ALIGNMENT - align data ΓòÉΓòÉΓòÉ
  1787.  
  1788. Modes: COMPILE 
  1789.  
  1790. If the option is set OFF, the compiler does not consider any alignment of data, 
  1791. otherwise it does. See Record types for further details. 
  1792.  
  1793. Note: the option cannot be used inline in the source text. 
  1794.  
  1795.  
  1796. ΓòÉΓòÉΓòÉ 7.2.4. ASSERT - enable ASSERT generation ΓòÉΓòÉΓòÉ
  1797.  
  1798. Modes: COMPILE (inline) 
  1799.  
  1800. If the option is OFF, the compiler ignores all calls of the standard ASSERT 
  1801. procedure. 
  1802.  
  1803. The option is ON by default. 
  1804.  
  1805.  
  1806. ΓòÉΓòÉΓòÉ 7.2.5. BSCLOSURE - browse control option ΓòÉΓòÉΓòÉ
  1807.  
  1808. Modes: BROWSE 
  1809.  
  1810. Include all visible methods. 
  1811.  
  1812. If the option is set ON, the browser includes all defined and inherited 
  1813. type-bound procedure declarations with all record declarations when creating a 
  1814. pseudo-definition module. See also Creating a definition. 
  1815.  
  1816.  
  1817. ΓòÉΓòÉΓòÉ 7.2.6. BSREDEFINE - browse control option ΓòÉΓòÉΓòÉ
  1818.  
  1819. Modes: BROWSE 
  1820.  
  1821. Include all redefined methods. 
  1822.  
  1823. If the option is set ON, the browser includes original definitions of any 
  1824. overwritten type-bound procedures with record declarations. See also Creating a 
  1825. definition. 
  1826.  
  1827.  
  1828. ΓòÉΓòÉΓòÉ 7.2.7. CHANGESYM - permission to change a symbol file ΓòÉΓòÉΓòÉ
  1829.  
  1830. Modes: COMPILE (header) 
  1831.  
  1832. Permission to change a module interface (a symbol file). 
  1833.  
  1834. The Oberon-2 compiler creates a temporary symbol file every time an Oberon-2 
  1835. module is compiled, compares this symbol file with the existing one and 
  1836. overwrites it with the new one if necessary. When the option is OFF (by 
  1837. default), the compiler reports an error if the symbol file (and the module 
  1838. interface respectively) had been changed and does not replace the old symbol 
  1839. file. 
  1840.  
  1841. Note: if the M2CMPSYM option is set, the same is valid for the compilation of 
  1842. the Modula-2 definition module, i.e., the CHANGESYM option should be set if the 
  1843. module interface has been changed. 
  1844.  
  1845.  
  1846. ΓòÉΓòÉΓòÉ 7.2.8. CHECKDINDEX - check of dynamic array bounds ΓòÉΓòÉΓòÉ
  1847.  
  1848. Modes: COMPILE (inline) 
  1849.  
  1850. A check of dynamic array bounds. 
  1851.  
  1852. If the option is set ON, the compiler generates index check of dynamic arrays 
  1853. (POINTER TO ARRAY OF T). 
  1854.  
  1855. The option is ON by default. 
  1856.  
  1857.  
  1858. ΓòÉΓòÉΓòÉ 7.2.9. CHECKDIV - check for a positive divisor (DIV and MOD) ΓòÉΓòÉΓòÉ
  1859.  
  1860. Modes: COMPILE (inline) 
  1861.  
  1862. If the option is set ON, the compiler generates a check if a divisor is 
  1863. positive of DIV and MOD operators. 
  1864.  
  1865. The option is ON by default. 
  1866.  
  1867.  
  1868. ΓòÉΓòÉΓòÉ 7.2.10. CHECKINDEX - check of static array bounds ΓòÉΓòÉΓòÉ
  1869.  
  1870. Modes: COMPILE (inline) 
  1871.  
  1872. A check of static array bounds. 
  1873.  
  1874. If the option is set ON, the compiler generates index check of all arrays 
  1875. except dynamic ones (See the CHECKDINDEX option). 
  1876.  
  1877. The option is ON by default. 
  1878.  
  1879.  
  1880. ΓòÉΓòÉΓòÉ 7.2.11. CHECKNIL - NIL pointer dereference check ΓòÉΓòÉΓòÉ
  1881.  
  1882. Modes: COMPILE (inline) 
  1883.  
  1884. If the option is set ON, the compiler generates NIL check of all pointer 
  1885. dereferencies. 
  1886.  
  1887. The option is ON by default. 
  1888.  
  1889.  
  1890. ΓòÉΓòÉΓòÉ 7.2.12. CHECKPROC - check of a formal procedure call ΓòÉΓòÉΓòÉ
  1891.  
  1892. Modes: COMPILE (inline) 
  1893.  
  1894. If the option is set ON, the compiler generates NIL check when calling a 
  1895. procedure variable. 
  1896.  
  1897. The option is ON by default. 
  1898.  
  1899.  
  1900. ΓòÉΓòÉΓòÉ 7.2.13. CHECKRANGE - range checks (range types and enumerations) ΓòÉΓòÉΓòÉ
  1901.  
  1902. Modes: COMPILE (inline) 
  1903.  
  1904. If the option is set ON, the compiler generates range checks of range types and 
  1905. enumerations. 
  1906.  
  1907. The option is ON by default. 
  1908.  
  1909.  
  1910. ΓòÉΓòÉΓòÉ 7.2.14. CHECKSET - range check of set operations ΓòÉΓòÉΓòÉ
  1911.  
  1912. Modes: COMPILE (inline) 
  1913.  
  1914. If the option is set ON, the compiler generates range checks of set operations 
  1915. (INCL, EXCL, set aggregates). 
  1916.  
  1917. The option is ON by default. 
  1918.  
  1919.  
  1920. ΓòÉΓòÉΓòÉ 7.2.15. CHECKTYPE - dynamic type guards (Oberon-2 only) ΓòÉΓòÉΓòÉ
  1921.  
  1922. Modes: COMPILE, Oberon-2 only (inline) 
  1923.  
  1924. If the option is set ON, the compiler generates dynamic type guards. 
  1925.  
  1926. The option is ON by default. 
  1927.  
  1928.  
  1929. ΓòÉΓòÉΓòÉ 7.2.16. COVERFLOW - cardinal overflow check ΓòÉΓòÉΓòÉ
  1930.  
  1931. Modes: COMPILE (inline) 
  1932.  
  1933. If the option is set ON, the compiler generates overflow checks of all cardinal 
  1934. (unsigned) arithmetic operators. 
  1935.  
  1936. The option is ON by default. 
  1937.  
  1938.  
  1939. ΓòÉΓòÉΓòÉ 7.2.17. DEFLIBS - put the default library names into object files ΓòÉΓòÉΓòÉ
  1940.  
  1941. Modes: COMPILE 
  1942.  
  1943. If the option is set ON, the compiler writes the default library names to the 
  1944. generated object files. 
  1945.  
  1946. The option is ON by default. 
  1947.  
  1948.  
  1949. ΓòÉΓòÉΓòÉ 7.2.18. DOREORDER - perform instruction scheduling ΓòÉΓòÉΓòÉ
  1950.  
  1951. Modes: COMPILE (header) 
  1952.  
  1953. Setting this option on enables the instruction scheduling mechanism of the x86 
  1954. code generator. It reorders CPU instructions to allow concurrent execution of 
  1955. their pairs on a Pentium processor (if the CPU option is not set to GENERIC). 
  1956.  
  1957. Note: this optimization significantly slows down the compiler, but results in a 
  1958. code perfomance gain of 5-15%. 
  1959.  
  1960.  
  1961. ΓòÉΓòÉΓòÉ 7.2.19. FATFS - limit file names to 8.3 ΓòÉΓòÉΓòÉ
  1962.  
  1963. Modes: * 
  1964.  
  1965. Forces the compiler to limit file names to FAT "8.3" convention. 
  1966.  
  1967.  
  1968. ΓòÉΓòÉΓòÉ 7.2.20. GCAUTO - enables implicit call of the garbage collector ΓòÉΓòÉΓòÉ
  1969.  
  1970. Modes: COMPILE,top-level module only (header) 
  1971.  
  1972. Enables an implicit call of the garbage collector in the generated program. The 
  1973. option is ignored for all modules except the top-level module of the program. 
  1974. We recommend to set the option in the project or configuration file. 
  1975.  
  1976.  
  1977. ΓòÉΓòÉΓòÉ 7.2.21. GENCPREF - generate underscore prefixes ΓòÉΓòÉΓòÉ
  1978.  
  1979. Modes: COMPILE 
  1980.  
  1981. If the option is set ON, the compiler appends underscore as a prefix for all 
  1982. names in object files. 
  1983.  
  1984.  
  1985. ΓòÉΓòÉΓòÉ 7.2.22. GENDEBUG - generate code in the debug mode ΓòÉΓòÉΓòÉ
  1986.  
  1987. Modes: COMPILE (header) 
  1988.  
  1989. If the option is set ON, the compiler puts additional debug information (in OMF 
  1990. format) into an object file. In the current release this information includes 
  1991. all global variables and its types. 
  1992.  
  1993. In some rare cases, switching the option ON may decrease the code quality. 
  1994.  
  1995.  
  1996. ΓòÉΓòÉΓòÉ 7.2.23. GENFRAME - always generate a procedure frame ΓòÉΓòÉΓòÉ
  1997.  
  1998. Modes: COMPILE (header) 
  1999.  
  2000. If the option is set ON, the compiler always generates a stack frame. It may be 
  2001. necessary to simplify the debugging. 
  2002.  
  2003.  
  2004. ΓòÉΓòÉΓòÉ 7.2.24. GENHISTORY - enable postmortem history ΓòÉΓòÉΓòÉ
  2005.  
  2006. Modes: COMPILE (header) 
  2007.  
  2008. If the option is set ON, the run-time system prints a stack of procedure calls 
  2009. (a file name and a line number) on abnormal termination of your program. It 
  2010. should be set when compiling a main module of the program. In this case the 
  2011. required part of the run-time system will be added to the program. The option 
  2012. LINENO should be set for all modules in the program. 
  2013.  
  2014. In some cases the printed list contains wrong lines, i.e. it contains 
  2015. procedures that were not called in the given context (See History). 
  2016.  
  2017. See also Debugging a program for an example. 
  2018.  
  2019.  
  2020. ΓòÉΓòÉΓòÉ 7.2.25. GENPTRINIT - generate a local pointer initialization ΓòÉΓòÉΓòÉ
  2021.  
  2022. Modes: COMPILE, Oberon-2 only (header) 
  2023.  
  2024. If the option is set ON, the compiler generates code for initialization all 
  2025. local pointers, including variables, record fields and array elements. Values 
  2026. of all non-pointer record fields and array elements are undefined. 
  2027.  
  2028. The option is ON by default. 
  2029.  
  2030.  
  2031. ΓòÉΓòÉΓòÉ 7.2.26. IOVERFLOW - integer overflow check ΓòÉΓòÉΓòÉ
  2032.  
  2033. Modes: COMPILE (inline) 
  2034.  
  2035. If the option is set ON, the compiler generates the overflow checks of all 
  2036. integer (signed) arithmetic operators. 
  2037.  
  2038. The option is ON by default. 
  2039.  
  2040.  
  2041. ΓòÉΓòÉΓòÉ 7.2.27. LINENO - generate line numbers ΓòÉΓòÉΓòÉ
  2042.  
  2043. Modes: COMPILE (header) 
  2044.  
  2045. If the option is set ON, the compiler insert line numbers information into the 
  2046. object files. This option should be set to get the postmorten history (See the 
  2047. GENHISTORY option) and for debugging. 
  2048.  
  2049.  
  2050. ΓòÉΓòÉΓòÉ 7.2.28. LONGNAME - use long names in batch files ΓòÉΓòÉΓòÉ
  2051.  
  2052. Modes: MAKE,PROJECT 
  2053.  
  2054. Use long names. 
  2055.  
  2056. If the option is set ON, the compiler uses the full path as the prefix to all 
  2057. module names in the generated batch files. See also BATCH submode. 
  2058.  
  2059.  
  2060. ΓòÉΓòÉΓòÉ 7.2.29. M2 - forces the Modula-2 compiler ΓòÉΓòÉΓòÉ
  2061.  
  2062. Modes: COMPILE 
  2063.  
  2064. Force the Modula-2 compiler. 
  2065.  
  2066. If the option is set ON, XDS invokes the Modula-2 compiler regardless of file 
  2067. extension. The option is ignored in MAKE and PROJECT modes. 
  2068.  
  2069.  
  2070. ΓòÉΓòÉΓòÉ 7.2.30. M2ADDTYPES - add SHORT and LONG types ΓòÉΓòÉΓòÉ
  2071.  
  2072. Modes: COMPILE,Modula-2 only (header) 
  2073.  
  2074. Add short and long modifications of whole types. 
  2075.  
  2076. If the option is set ON, the compiler recognizes the types SHORTINT, LONGINT, 
  2077. SHORTCARD and LONGCARD as pervasive identifiers . 
  2078.  
  2079. Warning: A use of additional types may cause problems with the software 
  2080. portability to other compilers. 
  2081.  
  2082.  
  2083. ΓòÉΓòÉΓòÉ 7.2.31. M2BASE16 - use 16-bits basic types in Modula-2 ΓòÉΓòÉΓòÉ
  2084.  
  2085. Modes: COMPILE,Modula-2 only (header) 
  2086.  
  2087. If the option is set ON, the basic types INTEGER, CARDINAL and BITSET are 16 
  2088. bits wide in Modula-2 (by default, 32 bits wide). 
  2089.  
  2090.  
  2091. ΓòÉΓòÉΓòÉ 7.2.32. M2CMPSYM - compare symbol files in Modula-2 ΓòÉΓòÉΓòÉ
  2092.  
  2093. Modes: COMPILE,Modula-2 only 
  2094.  
  2095. If the option is set ON, the compiler compares the symbol file generated for a 
  2096. definition module with the old version exactly as the Oberon-2 compiler does. 
  2097. If the symbol files are equal, the old one is preserved, otherwise the compiler 
  2098. overwrites symbol file, but only if the CHANGESYM option is set ON. 
  2099.  
  2100.  
  2101. ΓòÉΓòÉΓòÉ 7.2.33. M2EXTENSIONS - enables Modula-2 extensions ΓòÉΓòÉΓòÉ
  2102.  
  2103. Modes: COMPILE,Modula-2 only (header) 
  2104.  
  2105. Enable Modula-2 extensions. 
  2106.  
  2107. If the option is set ON, the compiler allows the Modula-2 language extensions 
  2108. to be used, such as line comment "-", read-only parameters, and so on. 
  2109.  
  2110. Warning: A use of extensions may cause problems with the software portability 
  2111. to other compilers. 
  2112.  
  2113.  
  2114. ΓòÉΓòÉΓòÉ 7.2.34. M2UNPACKTYPES - forces to use unpack form of some types ΓòÉΓòÉΓòÉ
  2115.  
  2116. Modes: COMPILE,Modula-2 only (header) 
  2117.  
  2118. If the option is set ON, the compiler uses 32-bit representation for Modula-2 
  2119. enumeration, set and BOOLEAN types. See Data representation for further 
  2120. details. 
  2121.  
  2122.  
  2123. ΓòÉΓòÉΓòÉ 7.2.35. MAIN - marks the Oberon-2 main module ΓòÉΓòÉΓòÉ
  2124.  
  2125. Modes: COMPILE, Oberon-2 only (header) 
  2126.  
  2127. Mark the Oberon-2 main module. 
  2128.  
  2129. If the option is set ON, the compiler generates a program entry point (`main' 
  2130. function) for the Oberon-2 module (See Program structure). Inline usage is 
  2131. recommended. 
  2132.  
  2133.  
  2134. ΓòÉΓòÉΓòÉ 7.2.36. MAKEDEF - generate definition ΓòÉΓòÉΓòÉ
  2135.  
  2136. Modes: COMPILE,Oberon-2 only 
  2137.  
  2138. Forces the Oberon compiler to generate a (pseudo-) definition module after a 
  2139. successful compilation of an Oberon module. The compiler preserves the 
  2140. so-called exported comments (i.e. comments started with `(**') if the XCOMMENTS 
  2141. option is set. 
  2142.  
  2143. See Creating a definition. 
  2144.  
  2145.  
  2146. ΓòÉΓòÉΓòÉ 7.2.37. MAKEFILE - generate makefile ΓòÉΓòÉΓòÉ
  2147.  
  2148. Modes: PROJECT 
  2149.  
  2150. Forces XDS to generate a makefile after successful compilation of a project. 
  2151. See also GEN mode. 
  2152.  
  2153.  
  2154. ΓòÉΓòÉΓòÉ 7.2.38. NOPTRALIAS - ignore the pointer aliasing ΓòÉΓòÉΓòÉ
  2155.  
  2156. Modes: COMPILE (header) 
  2157.  
  2158. If the option is set ON, the compiler assumes that there is no pointer 
  2159. aliasing, i.e. there are no pointers bounded to non-structure variables. The 
  2160. only way to get a pointer to a variable is to use the low-level facilities from 
  2161. the module SYSTEM. We recommend to turn this option ON for all modules except 
  2162. low-level ones. Note: the code quality is better if the option is ON. 
  2163.  
  2164.  
  2165. ΓòÉΓòÉΓòÉ 7.2.39. O2 - forces the Oberon-2 compiler ΓòÉΓòÉΓòÉ
  2166.  
  2167. Modes: COMPILE 
  2168.  
  2169. Force Oberon-2 compiler. 
  2170.  
  2171. If the option is set ON, XDS invokes the Oberon-2 compiler regardless of the 
  2172. file extension. The option is ignored in MAKE and PROJECT modes. 
  2173.  
  2174.  
  2175. ΓòÉΓòÉΓòÉ 7.2.40. O2EXTENSIONS - enables Oberon-2 extensions ΓòÉΓòÉΓòÉ
  2176.  
  2177. Modes: COMPILE,Oberon-2 only (header) 
  2178.  
  2179. Enable Oberon-2 extensions. 
  2180.  
  2181. If the option is set ON, the compiler allows Oberon-2 language extensions to be 
  2182. used (See Language extensions). 
  2183.  
  2184. Warning: A use of extensions may cause problems with the software portability 
  2185. to other compilers. 
  2186.  
  2187.  
  2188. ΓòÉΓòÉΓòÉ 7.2.41. O2ISOPRAGMA - enable ISO Modula-2 pragmas in Oberon ΓòÉΓòÉΓòÉ
  2189.  
  2190. Modes: COMPILE,Oberon-2 only 
  2191.  
  2192. If the option is set ON, the compiler allows the ISO M2 style pragmas <* *> to 
  2193. be used in Oberon-2. See Source code directives and Source code directives. 
  2194.  
  2195. Warning: A use of ISO M2 pragmas may cause problems with the software 
  2196. portability to other compilers. 
  2197.  
  2198.  
  2199. ΓòÉΓòÉΓòÉ 7.2.42. O2NUMEXT - enable Oberon-2 scientific extension ΓòÉΓòÉΓòÉ
  2200.  
  2201. Modes: COMPILE,Oberon-2 only (header) 
  2202.  
  2203. Enable Oberon-2 scientific extensions. 
  2204.  
  2205. If the option is set ON, the compiler allows the Oberon-2 scientific language 
  2206. extensions to be used (See Language extensions), including COMPLEX and 
  2207. LONGCOMPLEX types and the in-line exponentiation operator. 
  2208.  
  2209. Warning: A use of additional types may cause problems with the software 
  2210. portability to other compilers. 
  2211.  
  2212.  
  2213. ΓòÉΓòÉΓòÉ 7.2.43. ONECODESEG - generate one code segment ΓòÉΓòÉΓòÉ
  2214.  
  2215. Modes: COMPILE 
  2216.  
  2217. If the option is ON, the compiler produces only one code segment which contains 
  2218. all code of a module, otherwise it generates separate code segment for each 
  2219. procedure. 
  2220.  
  2221.  
  2222. ΓòÉΓòÉΓòÉ 7.2.44. OVERWRITE - create a file, always overwrites the old one ΓòÉΓòÉΓòÉ
  2223.  
  2224. Modes: * 
  2225.  
  2226. The option changes the directory where the compiler creates new files. If the 
  2227. option is OFF, the compiler creates a file in the directory which appears first 
  2228. in the search path list appropriate to the filename pattern. Otherwise, the 
  2229. compiler overwrites the old file. See also Redirection file. 
  2230.  
  2231.  
  2232. ΓòÉΓòÉΓòÉ 7.2.45. PROCINLINE - enables in-line procedure's expansion ΓòÉΓòÉΓòÉ
  2233.  
  2234. Modes: COMPILE 
  2235.  
  2236. If the option is ON, the compiler tries to expand procedures in-line. In-line 
  2237. expansion of a procedure saves the overhead usually associated with procedure 
  2238. calls, parameter passing, register saving, etc. Sometimes, further 
  2239. optimizations become possible because the actual parameters used in the call 
  2240. become visible. 
  2241.  
  2242. A procedure is not expanded in-line under the following circumstances: 
  2243.  
  2244.      the procedure is deemed too complex or too large by the compiler. 
  2245.  
  2246.      there are too many calls of the procedure. 
  2247.  
  2248.      the procedure is recursive. 
  2249.  
  2250.  
  2251. ΓòÉΓòÉΓòÉ 7.2.46. SHOWALIEN - produce warnings on absent modules ΓòÉΓòÉΓòÉ
  2252.  
  2253. Modes: MAKE,PROJECT,GEN 
  2254.  
  2255. If the option is set ON, the compiler reports a list of all Modula-2 or 
  2256. Oberon-2 modules which are not found within the current project. 
  2257.  
  2258.  
  2259. ΓòÉΓòÉΓòÉ 7.2.47. SPACE - code size is more important then speed ΓòÉΓòÉΓòÉ
  2260.  
  2261. Modes: COMPILE 
  2262.  
  2263. If the option is set ON, the compiler performs optimizations to produce smaller 
  2264. code, otherwise (by default) to produce faster code. 
  2265.  
  2266.  
  2267. ΓòÉΓòÉΓòÉ 7.2.48. STORAGE - enables the default memory management in Modula-2 ΓòÉΓòÉΓòÉ
  2268.  
  2269. Modes: COMPILE, Modula-2 only (header) 
  2270.  
  2271. If the option is set ON, the compiler uses the default memory allocation and 
  2272. deallocation procedures for standard procedures NEW and DISPOSE. 
  2273.  
  2274. Warning: A use of this option may cause problems with the software portability 
  2275. to other compilers. 
  2276.  
  2277.  
  2278. ΓòÉΓòÉΓòÉ 7.2.49. VERBOSE - produce verbose messages ΓòÉΓòÉΓòÉ
  2279.  
  2280. Modes: MAKE,PROJECT 
  2281.  
  2282. If the option is set ON, the compiler will report the reason of a module 
  2283. recompilation (See Smart recompilation). 
  2284.  
  2285.  
  2286. ΓòÉΓòÉΓòÉ 7.2.50. VERSIONKEY - append version key to the module initialization ΓòÉΓòÉΓòÉ
  2287.  
  2288. Modes: COMPILE 
  2289.  
  2290. The option is introduced to perform version checks at a link time. If the 
  2291. option is set ON, the compiler generates the name of module body as composition 
  2292. of 
  2293.  
  2294.      a module name 
  2295.  
  2296.      a string "_BEGIN_" 
  2297.  
  2298.      a time stamp 
  2299.  
  2300.      value of the ALIGNMENT option. 
  2301.  
  2302.  If the definition (or Oberon-2) module imported by different compilation units 
  2303.  has the same version, the same name is generated for each call of the module 
  2304.  body. In all other cases unresolved references will occur at link time. 
  2305.  
  2306.  If the option is OFF, the compiler generates the name in the form: 
  2307.  <module_name>_BEGIN. 
  2308.  
  2309.  Note: the option should be set when compiling definition or Oberon module. 
  2310.  
  2311.  
  2312. ΓòÉΓòÉΓòÉ 7.2.51. WOFF - suppresse warning messages ΓòÉΓòÉΓòÉ
  2313.  
  2314. Modes: * (inline) 
  2315.  
  2316. When WOFF# (e.g. WOFF301) is ON, the compiler does not report a warning # (301 
  2317. in the above example). See xc.msg file for warning texts and numbers. WOFF 
  2318. without parameter sets all warnings OFF. 
  2319.  
  2320.  
  2321. ΓòÉΓòÉΓòÉ 7.2.52. XCOMMENTS - preserve exported comments ΓòÉΓòÉΓòÉ
  2322.  
  2323. Modes: COMPILE,Oberon-2 only 
  2324.  
  2325. If the option is set ON, the browser includes the so-called exported comments 
  2326. (i.e. comments which start with `(**') into the generated pseudo definition 
  2327. module. 
  2328.  
  2329. See also Creating a definition. 
  2330.  
  2331.  
  2332. ΓòÉΓòÉΓòÉ 7.3. Equations ΓòÉΓòÉΓòÉ
  2333.  
  2334. An equation is a pair (name,value). Equations are used for a change of default 
  2335. file extensions (table Examples, page table:equ:ext), code generation settings 
  2336. (table Examples, page table:equ:code) and miscellaneous settings (table 
  2337. Examples, page table:equ:misc) by the statements of the form: 
  2338.  
  2339.   -NAME=value
  2340.  
  2341. There should be no spaces in an equation statement on the command line. In the 
  2342. configuration or project file, spaces can be placed anywhere, but only one 
  2343. equation per line is allowed (see Options). 
  2344.  
  2345. Equations may be set in the configuration file (See Configuration file), in the 
  2346. project file (See Project files) and on the command line, but not in the source 
  2347. text. At any point of operation, the most recent value of an equation is in 
  2348. effect. All equations are listed in the section Equations. 
  2349.  
  2350. In some cases, the value part of an equation statement may be empty. 
  2351. Examples 
  2352.  
  2353. -mod = .mod
  2354. -DEF = .def
  2355. -mkfext =
  2356.  
  2357. [htbp] 
  2358.  
  2359. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2360.  Name    Default  Meaning
  2361.  
  2362.  BATEXT  .bat     recompilation batch file
  2363.  
  2364.  BSDEF   .odf     pseudo-definition file created by browser
  2365.  
  2366.  CODE    .obj     object file
  2367.  
  2368.  DEF     .def     Modula-2 definition module
  2369.  
  2370.  MKFEXT  .mkf     makefile
  2371.  
  2372.  MOD     .mod     Modula-2 implementation or main module
  2373.  
  2374.  OBERON  .ob2     Oberon-2 module
  2375.  
  2376.  OBJEXT  .obj     object file
  2377.  
  2378.  PRJEXT  .prj     project file
  2379.  
  2380.  SYM     .sym     symbol file
  2381. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2382.  
  2383. File extensions 
  2384.  
  2385. [htbp] 
  2386.  
  2387. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2388.  Name         Default  Meaning
  2389.  
  2390.  CC           WATCOM   C compiler compatibility
  2391.  
  2392.  CPU          GENERIC  CPU to optimize for
  2393.  
  2394.  GCTHRESHOLD  0        garbage collector threshold
  2395.  
  2396.  HEAPLIMIT    0        heap limit of a generated program
  2397.  
  2398.  MINCPU       386      minimal CPU required for execution
  2399.  
  2400.  STACKLIMIT   0        stack limit of a generated program
  2401. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2402.  
  2403. Code generator equations 
  2404.  
  2405. [htbp] 
  2406.  
  2407. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2408.  Name           Default                                 Meaning
  2409.  
  2410.  ATTENTION      !                                       attention character in a template file
  2411.  
  2412.  BATNAME        out                                     batch file name
  2413.  
  2414.  BATWIDTH       128                                     maximum line width in a batch file
  2415.  
  2416.  BSTYLE         DEF                                     browse style (See Creating a definition)
  2417.  
  2418.  COMPILERHEAP                                           heap limit of the compiler
  2419.  
  2420.  COMPILERTHRES                                          GC threshold of the compiler
  2421.  
  2422.  DECOR          hrtp                                    control of compiler messages
  2423.  
  2424.  ERRFMT         See Error message format specification  error message format
  2425.  
  2426.  ERRLIM         16                                      maximum number of errors
  2427.  
  2428.  LINK                                                   linker command line
  2429.  
  2430.  LOOKUP                                                 lookup directive
  2431.  
  2432.  MKFNAME                                                makefile name
  2433.  
  2434.  PRJ                                                    project file name
  2435.  
  2436.  PROJECT                                                project name
  2437.  
  2438.  TABSTOP        8                                       tabulation alignment
  2439.  
  2440.  TEMPLATE                                               template name (for makefile)
  2441. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2442.  
  2443. Miscellaneous equations 
  2444.  
  2445.  
  2446. ΓòÉΓòÉΓòÉ 7.4. Description of equations ΓòÉΓòÉΓòÉ
  2447.  
  2448. The operation modes to which an equation is significant are enclosed in square 
  2449. brackets ([]) after the option name; the character '*' stands for all operation 
  2450. modes. For example [browse] means that the equation is used by the compiler in 
  2451. the BROWSE operation mode only. Note: the compiler switches from the MAKE and 
  2452. PROJECT mode to the COMPILE mode to compile a module. 
  2453.  
  2454.      ATTENTION - attention character in a template file 
  2455.      BATEXT - recompilation batch file extension 
  2456.      BATNAME - batch file name 
  2457.      BATWIDTH - maximum line width in a batch file 
  2458.      BSDEF - pseudo-definition file created by browser extension 
  2459.      BSTYLE - browse style 
  2460.      CC - C compiler compatibility 
  2461.      CODE - object file extension 
  2462.      COMPILERHEAP - heap limit of the compiler 
  2463.      COMPILERTHRES - GC threshold of the compiler 
  2464.      CPU - CPU to optimize for 
  2465.      DECOR - control of compiler messages 
  2466.      DEF - Modula-2 definition module extension 
  2467.      ERRFMT - error message format 
  2468.      ERRLIM - maximum number of errors 
  2469.      GCTHRESHOLD - garbage collector threshold 
  2470.      HEAPLIMIT - heap limit of a generated program 
  2471.      LINK - linker command line 
  2472.      LOOKUP - lookup directive 
  2473.      MINCPU - minimal CPU required for execution 
  2474.      MKFEXT - makefile extension 
  2475.      MKFNAME - makefile name 
  2476.      MOD - Modula-2 implementation or main module extension 
  2477.      OBERON - Oberon-2 module extension 
  2478.      OBJEXT - object file extension 
  2479.      PRJ - project file name 
  2480.      PRJEXT - project file extension 
  2481.      PROJECT - project name 
  2482.      STACKLIMIT - stack limit of a generated program 
  2483.      SYM - symbol file extension 
  2484.      TABSTOP - tabulation alignment 
  2485.      TEMPLATE - template name (for makefile) 
  2486.  
  2487.  
  2488. ΓòÉΓòÉΓòÉ 7.4.1. ATTENTION - attention character in a template file ΓòÉΓòÉΓòÉ
  2489.  
  2490. Modes: PROJECT,GEN 
  2491.  
  2492. The equation defines an attention character which is used in the template file 
  2493. ("!" by default). See Template files. 
  2494.  
  2495.  
  2496. ΓòÉΓòÉΓòÉ 7.4.2. BATEXT - recompilation batch file extension ΓòÉΓòÉΓòÉ
  2497.  
  2498. Modes: MAKE,PROJECT,batch submode 
  2499.  
  2500. Sets the file extension for recompilation batch files (by default .bat). See 
  2501. BATCH submode. 
  2502.  
  2503.  
  2504. ΓòÉΓòÉΓòÉ 7.4.3. BATNAME - batch file name ΓòÉΓòÉΓòÉ
  2505.  
  2506. Modes: MAKE,PROJECT,batch submode 
  2507.  
  2508. Sets the batch file name. 
  2509.  
  2510. The name of the Project file will be used if no batch file name is explicitly 
  2511. specified. See BATCH submode. 
  2512.  
  2513.  
  2514. ΓòÉΓòÉΓòÉ 7.4.4. BATWIDTH - maximum line width in a batch file ΓòÉΓòÉΓòÉ
  2515.  
  2516. Modes: MAKE,PROJECT,batch submode 
  2517.  
  2518. Sets the maximum width of a line in a generated batch file (by default 128). 
  2519. See BATCH submode. 
  2520.  
  2521.  
  2522. ΓòÉΓòÉΓòÉ 7.4.5. BSDEF - pseudo-definition file created by browser extension ΓòÉΓòÉΓòÉ
  2523.  
  2524. Modes: BROWSE 
  2525.  
  2526. Sets the file extension for pseudo-definition modules created by the browser 
  2527. (by default .odf). See BROWSE mode. 
  2528.  
  2529.  
  2530. ΓòÉΓòÉΓòÉ 7.4.6. BSTYLE - browse style ΓòÉΓòÉΓòÉ
  2531.  
  2532. Modes: BROWSE 
  2533.  
  2534. Sets the style of generated pseudo-definition modules. See Creating a 
  2535. definition. 
  2536.  
  2537.  
  2538. ΓòÉΓòÉΓòÉ 7.4.7. CC - C compiler compatibility ΓòÉΓòÉΓòÉ
  2539.  
  2540. Modes: COMPILE 
  2541.  
  2542. Sets the compatibility mode with a C compiler. Currently the following values 
  2543. are defined: "WATCOM" and "MSVC". If the value of equation is undefined, 
  2544. "WATCOM" is assumed. 
  2545.  
  2546. The compiler will allow one to use C libraries from the C compiler specified. 
  2547.  
  2548. See Chapter Configuring XDS for a C Compiler for more details. 
  2549.  
  2550.  
  2551. ΓòÉΓòÉΓòÉ 7.4.8. CODE - object file extension ΓòÉΓòÉΓòÉ
  2552.  
  2553. Modes: * 
  2554.  
  2555. Sets the file extension for code files generated by the compiler (by default 
  2556. .obj). 
  2557.  
  2558.  
  2559. ΓòÉΓòÉΓòÉ 7.4.9. COMPILERHEAP - heap limit of the compiler ΓòÉΓòÉΓòÉ
  2560.  
  2561. Modes: * 
  2562.  
  2563. Sets the maximum amount of a heap memory (in bytes), that can be used by the 
  2564. compiler. For the systems with virtual memory, we recommend to use the value 
  2565. which is less than the amount of the physical memory. 
  2566.  
  2567.  
  2568. ΓòÉΓòÉΓòÉ 7.4.10. COMPILERTHRES - GC threshold of the compiler ΓòÉΓòÉΓòÉ
  2569.  
  2570. Modes: * 
  2571.  
  2572. Sets the garbage collector threshold (in bytes) for the compiler. The garbage 
  2573. collector will be implicitly called if the amount of a busy memory exceeds the 
  2574. value of the equation. For the systems with virtual memory, we recommend to use 
  2575. the value which is less than COMPILERHEAP. 
  2576.  
  2577.  
  2578. ΓòÉΓòÉΓòÉ 7.4.11. CPU - CPU to optimize for ΓòÉΓòÉΓòÉ
  2579.  
  2580. Modes: COMPILE 
  2581.  
  2582. Specifies on which Intel x86 family representative the resulting program will 
  2583. be executed optimally. 
  2584.  
  2585. Valid values: "386", "486", "PENTIUM", and "PENTIUMPRO". The value must be 
  2586. "greater of equal" than the value of the MINCPU equation. 
  2587.  
  2588. There is also the special value "GENERIC", which means that optimizer should 
  2589. not perform code transformations that may significantly reduce performance on a 
  2590. particular CPU. 
  2591.  
  2592.  
  2593. ΓòÉΓòÉΓòÉ 7.4.12. DECOR - control of compiler messages ΓòÉΓòÉΓòÉ
  2594.  
  2595. Modes: * 
  2596.  
  2597. The equation specifies the output of the xc utility. The value of equation is a 
  2598. string that contains any combination of letters "h", "t" "c", "r", "p" (capital 
  2599. letters are also allowed). Each character turn on an output of 
  2600.  
  2601.  h         header line, which contains the name and version of the compiler's 
  2602.            front-end and back-end 
  2603.  
  2604.  p         progress messages 
  2605.  
  2606.  r         compiler report: number of errors, lines, etc. 
  2607.  
  2608.  t         the summary of compilation of multiple files 
  2609.  
  2610.  By default, the equation value is "hrt". 
  2611.  
  2612.  
  2613. ΓòÉΓòÉΓòÉ 7.4.13. DEF - Modula-2 definition module extension ΓòÉΓòÉΓòÉ
  2614.  
  2615. Modes: * 
  2616.  
  2617. Sets the file extension for Modula-2 definition modules (by default .def). 
  2618.  
  2619.  
  2620. ΓòÉΓòÉΓòÉ 7.4.14. ERRFMT - error message format ΓòÉΓòÉΓòÉ
  2621.  
  2622. Modes: * 
  2623.  
  2624. Sets the error message format. See Error message format specification for 
  2625. details. 
  2626.  
  2627.  
  2628. ΓòÉΓòÉΓòÉ 7.4.15. ERRLIM - maximum number of errors ΓòÉΓòÉΓòÉ
  2629.  
  2630. Modes: * 
  2631.  
  2632. Sets the maximum number of errors allowed for one compilation unit (by default 
  2633. 16). 
  2634.  
  2635.  
  2636. ΓòÉΓòÉΓòÉ 7.4.16. GCTHRESHOLD - garbage collector threshold ΓòÉΓòÉΓòÉ
  2637.  
  2638. Modes: COMPILE,top-level module only 
  2639.  
  2640. Sets the garbage collector threshold (in bytes). The garbage collector will be 
  2641. implicitly called if the amount of a busy memory exceeds the value of the 
  2642. equation. The valid values of the equation are in the range 0..HEAPLIMIT. We 
  2643. recommend to set the equation for the systems with virtual memory. 
  2644.  
  2645.  
  2646. ΓòÉΓòÉΓòÉ 7.4.17. HEAPLIMIT - heap limit of a generated program ΓòÉΓòÉΓòÉ
  2647.  
  2648. Modes: COMPILE,top-level module only 
  2649.  
  2650. Sets the maximum amount of a heap memory, that can be used in the generated 
  2651. program. The value is set in bytes. 
  2652.  
  2653. The equation should be set when the top-level module of the program is 
  2654. compiled. We recommend to set the option in the project or configuration file. 
  2655.  
  2656.  
  2657. ΓòÉΓòÉΓòÉ 7.4.18. LINK - linker command line ΓòÉΓòÉΓòÉ
  2658.  
  2659. Modes: PROJECT 
  2660.  
  2661. Defines a command line, which will be executed after a successful completion of 
  2662. a project. As a rule, the equation is used for calling a linker or make 
  2663. utility. 
  2664.  
  2665. See Running a program for examples. 
  2666.  
  2667.  
  2668. ΓòÉΓòÉΓòÉ 7.4.19. LOOKUP - lookup directive ΓòÉΓòÉΓòÉ
  2669.  
  2670. Modes: * 
  2671.  
  2672. Sets the lookup directive: 
  2673.  
  2674.   -LOOKUP = pattern = directory {";" directory }
  2675.  
  2676. The equation can be used for redefining the search paths that are set in the 
  2677. redirection file. The configuration or project file or command line can contain 
  2678. several LOOKUP equations. See also Configuration file and Project files. 
  2679.  
  2680.  
  2681. ΓòÉΓòÉΓòÉ 7.4.20. MINCPU - minimal CPU required for execution ΓòÉΓòÉΓòÉ
  2682.  
  2683. Modes: COMPILE 
  2684.  
  2685. Specifies an Intel x86 family representative which (or higher) is requried for 
  2686. the resulting program to be executed. 
  2687.  
  2688. Valid values: "GENERIC", "386", "486", "PENTIUM", and "PENTIUMPRO". For this 
  2689. equation, "GENERIC" is equivalent to "386". The value of the CPU equation must 
  2690. be "greater of equal" than the value of this equation. 
  2691.  
  2692.  
  2693. ΓòÉΓòÉΓòÉ 7.4.21. MKFEXT - makefile extension ΓòÉΓòÉΓòÉ
  2694.  
  2695. Modes: GEN 
  2696.  
  2697. Sets the file extension for a generated makefile (by default .mkf). See GEN 
  2698. mode. 
  2699.  
  2700.  
  2701. ΓòÉΓòÉΓòÉ 7.4.22. MKFNAME - makefile name ΓòÉΓòÉΓòÉ
  2702.  
  2703. Modes: GEN 
  2704.  
  2705. Sets the name for a generated makefile. See GEN mode. 
  2706.  
  2707.  
  2708. ΓòÉΓòÉΓòÉ 7.4.23. MOD - Modula-2 implementation or main module extension ΓòÉΓòÉΓòÉ
  2709.  
  2710. Modes: * 
  2711.  
  2712. Sets the file extension for the Modula-2 implementation and program modules (by 
  2713. default .mod). 
  2714.  
  2715.  
  2716. ΓòÉΓòÉΓòÉ 7.4.24. OBERON - Oberon-2 module extension ΓòÉΓòÉΓòÉ
  2717.  
  2718. Modes: * 
  2719.  
  2720. Sets the file extension for Oberon-2 modules (by default .ob2). 
  2721.  
  2722.  
  2723. ΓòÉΓòÉΓòÉ 7.4.25. OBJEXT - object file extension ΓòÉΓòÉΓòÉ
  2724.  
  2725. Modes: * 
  2726.  
  2727. Sets the file extension for object files (by default .obj). 
  2728.  
  2729.  
  2730. ΓòÉΓòÉΓòÉ 7.4.26. PRJ - project file name ΓòÉΓòÉΓòÉ
  2731.  
  2732. Modes: COMPILE,MAKE,PROJECT 
  2733.  
  2734. In the COMPILE and MAKE operation modes, the equation defines a project file to 
  2735. read settings from. In the PROJECT mode, the compiler sets this equation to a 
  2736. project file name from the command line. See PROJECT mode. 
  2737.  
  2738.  
  2739. ΓòÉΓòÉΓòÉ 7.4.27. PRJEXT - project file extension ΓòÉΓòÉΓòÉ
  2740.  
  2741. Modes: COMPILE,MAKE,PROJECT 
  2742.  
  2743. Sets the file extension for a project file (by default .prj). See PROJECT mode. 
  2744.  
  2745.  
  2746. ΓòÉΓòÉΓòÉ 7.4.28. PROJECT - project name ΓòÉΓòÉΓòÉ
  2747.  
  2748. Modes: COMPILE,MAKE,PROJECT 
  2749.  
  2750. If a project file name is defined, the compiler sets the equation to a project 
  2751. name without a file path and extension. For example, if the project file name 
  2752. is defined as prj/Work.prj, the value of the equation is set to Work. The 
  2753. equation may be used in a template file to set the name of executable file, 
  2754. etc. 
  2755.  
  2756.  
  2757. ΓòÉΓòÉΓòÉ 7.4.29. STACKLIMIT - stack limit of a generated program ΓòÉΓòÉΓòÉ
  2758.  
  2759. Modes: COMPILE,top-level module only 
  2760.  
  2761. Sets the maximum size of program stack memory. The value is set in bytes. 
  2762.  
  2763. The equation should be set when the top-level module of the program is 
  2764. compiled. We recommend to set the option in the project or configuration file. 
  2765.  
  2766. Note: for some linkers the stack size should be set as a linker option. 
  2767.  
  2768.  
  2769. ΓòÉΓòÉΓòÉ 7.4.30. SYM - symbol file extension ΓòÉΓòÉΓòÉ
  2770.  
  2771. Modes: * 
  2772.  
  2773. Sets the file extension for symbol files (by default .sym). See Files generated 
  2774. during compilation. 
  2775.  
  2776.  
  2777. ΓòÉΓòÉΓòÉ 7.4.31. TABSTOP - tabulation alignment ΓòÉΓòÉΓòÉ
  2778.  
  2779. Modes: GEN 
  2780.  
  2781. When reading text files, XDS replaces TAB character by the number of spaces 
  2782. required to align a text (by default TABSTOP is equal to 8). The wrong value 
  2783. may cause misplaced comments in the generated pseudo-definition module, a wrong 
  2784. location of an error in the error message, etc. We recommend to set this 
  2785. equation to the number used in your text editor. 
  2786.  
  2787.  
  2788. ΓòÉΓòÉΓòÉ 7.4.32. TEMPLATE - template name (for makefile) ΓòÉΓòÉΓòÉ
  2789.  
  2790. Modes: GEN 
  2791.  
  2792. Sets the name of a template file. See Template files. 
  2793.  
  2794.  
  2795. ΓòÉΓòÉΓòÉ 7.5. Error message format specification ΓòÉΓòÉΓòÉ
  2796.  
  2797. The format in which XDS reports the errors is user configurable by using the 
  2798. ERRFMT equation. Its syntax is as follows: 
  2799.  
  2800.   { string "," [ argument ] ";" }.
  2801.  
  2802. Any format specification allowed in the C procedure "printf" can be used in 
  2803. string. 
  2804.  
  2805. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2806.  Argument  Type     Meaning
  2807.  
  2808.  line      integer  position in a source text
  2809.  
  2810.  column    integer  position in a source text
  2811.  
  2812.  file      string   name of a source file
  2813.  
  2814.  module    string   module name
  2815.  
  2816.  errmsg    string   message text
  2817.  
  2818.  errno     integer  error code
  2819.  
  2820.  language  string   Oberon-2 or Modula-2
  2821.  
  2822.  mode      string   ERROR or WARNING or FAULT
  2823.  
  2824.  utility   string   name of an utility
  2825. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2826.  
  2827. Argument names are not case sensitive. By default the error format includes the 
  2828. following clauses: 
  2829.  
  2830. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2831.  "(%s",file;        -   a file name
  2832.  
  2833.  "%d",line;         -   a line number
  2834.  
  2835.  ",%d",column;      -   a column number
  2836.  
  2837.  ") [%.1s] ",mode;  -   the first letter of an error mode
  2838.  
  2839.  "%s\n",errmsg;     -   an error message
  2840. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2841.  
  2842. If the warning is reported in the file test.mod on line 5, column 6, the 
  2843. generated error message will look like this: 
  2844.  
  2845. (test.mod 5,6) [W] variable declared but never used
  2846.  
  2847.  
  2848. ΓòÉΓòÉΓòÉ 8. XDS Modula-2 ΓòÉΓòÉΓòÉ
  2849.  
  2850. This chapter includes the details of Modula-2 language which are specific to 
  2851. this implementation. In the standard modeWhen options M2EXTENSIONS and 
  2852. M2ADDTYPES are OFF XDS Modula-2 complies with International Standard (See the 
  2853. statement of compliance and further details in ISO Standard compliance). The 
  2854. compatibility rules are described in Compatibility. The differences between ISO 
  2855. Modula-2 and the language described in the 4th edition of Wirth's ``Programming 
  2856. in Modula-2'' PIM are listed in New language's features. Language extensions 
  2857. are described in Language extensions. 
  2858.  
  2859.      ISO Standard compliance 
  2860.      New language's features 
  2861.      Standard procedures 
  2862.      Compatibility 
  2863.      The module SYSTEM 
  2864.      Language extensions 
  2865.      Source code directives 
  2866.  
  2867.  
  2868. ΓòÉΓòÉΓòÉ 8.1. ISO Standard compliance ΓòÉΓòÉΓòÉ
  2869.  
  2870. XDS Modula-2 partially complies with the requirements of ISO 10514. The details 
  2871. of non-conformities are as follows: 
  2872.  
  2873.      Not all libraries are available in the current release. 
  2874.  
  2875.      The current release may impose some restrictions on using new language 
  2876.       features. 
  2877.  
  2878.  See Chapter Implementation limitations and restrictions for further details. 
  2879.  
  2880.      Ordering of declarations 
  2881.  
  2882.  
  2883. ΓòÉΓòÉΓòÉ 8.1.1. Ordering of declarations ΓòÉΓòÉΓòÉ
  2884.  
  2885. XDS Modula-2 is a so-called `single-pass' implementation. It means that all 
  2886. identifiers must be declared before use. According to the International 
  2887. Standard this declare-before-use approach is perfectly valid. The alternative 
  2888. approach (declare-before-use-in-declarations) can be used in the so-called 
  2889. `multi-pass' implementations. 
  2890.  
  2891. A forward declaration must be used to allow forward references to a procedure 
  2892. whose actual declaration appears later in the text. 
  2893. Example 
  2894.  
  2895. PROCEDURE a(x: INTEGER); FORWARD;
  2896. (* FORWARD declaration *)
  2897.  
  2898. PROCEDURE b(x: INTEGER);
  2899. BEGIN
  2900.   a(x-1);
  2901. END b;
  2902.  
  2903. PROCEDURE a(n: INTEGER);
  2904. (* proper procedure declaration *)
  2905. BEGIN
  2906.   b(n-1);
  2907. END a;
  2908.  
  2909. To provide a source compatibility between `single-pass' and `multi-pass' 
  2910. implementation, the standard demands that all conforming `multi-pass' 
  2911. implementations accept and correctly process the FORWARD directive. 
  2912.  
  2913.  
  2914. ΓòÉΓòÉΓòÉ 8.2. New language's features ΓòÉΓòÉΓòÉ
  2915.  
  2916. The language described in the International Standard varies in many details 
  2917. from that one described in Wirth's ``Programming in Modula-2'' PIM. The most 
  2918. important innovations are 
  2919.  
  2920.      complex numbers 
  2921.  
  2922.      module finalization 
  2923.  
  2924.      exception handling 
  2925.  
  2926.      array and record constructors 
  2927.  
  2928.      four new system modules 
  2929.  
  2930.      standard library 
  2931.  
  2932.  Note: The system modules (except the module SYSTEM) are not embedded in the 
  2933.  compiler and are implemented as separate modules. 
  2934.  
  2935.      Lexis 
  2936.      Complex types 
  2937.      Sets and packedsets 
  2938.      Strings 
  2939.      Value constructors 
  2940.      Multi-dimensional open arrays 
  2941.      Procedure type declarations 
  2942.      Procedure constants 
  2943.      Whole number division 
  2944.      Type conversions 
  2945.      NEW and DISPOSE 
  2946.      Finalization 
  2947.      Exceptions 
  2948.      The system module EXCEPTIONS 
  2949.      The system module M2EXCEPTION 
  2950.      Termination 
  2951.      Coroutines 
  2952.      Protection 
  2953.  
  2954.  
  2955. ΓòÉΓòÉΓòÉ 8.2.1. Lexis ΓòÉΓòÉΓòÉ
  2956.  
  2957. The ISO Modula-2 appends new keywords (table Lexis, page table:m2:ISO:keywords) 
  2958. and pervasive identifiers (table Lexis, page table:m2:ISO:pervasive), and 
  2959. provides alternatives for some symbols (table Lexis, page table:m2:ISO:alt). It 
  2960. also introduces a syntax for source code directives (or pragmas): 
  2961.  
  2962. pragma = "<*" pragma_body "*>"
  2963.  
  2964. The standard does not specify a syntax of pragma_body. In XDS, source code 
  2965. directives are used for the in-line option control and for the source control 
  2966. (conditional compilation). See Source code directives for further details. 
  2967.  
  2968. [bht] 
  2969.  
  2970. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2971.  AND                          ARRAY                BEGIN
  2972.  
  2973.  BY                           CASE                 CONST
  2974.  
  2975.  DEFINITION                   DIV                  DO
  2976.  
  2977.  ELSE                         ELSIF                END
  2978.  
  2979.  EXIT                         EXCEPT (Exceptions)  EXPORT
  2980.  
  2981.  FINALLY (Finalization)       FOR                  FORWARD (Ordering of declarations)
  2982.  
  2983.  FROM                         IF                   IMPLEMENTATION
  2984.  
  2985.  IMPORT                       IN                   LOOP
  2986.  
  2987.  MOD                          MODULE               NOT
  2988.  
  2989.  OF                           OR                   PACKEDSET (Sets and packedsets)
  2990.  
  2991.  PROCEDURE                    QUALIFIED            RECORD
  2992.  
  2993.  REM (Whole number division)  RETRY (Exceptions)   REPEAT
  2994.  
  2995.  RETURN                       SET                  THEN
  2996.  
  2997.  TO                           TYPE                 UNTIL
  2998.  
  2999.  VAR                          WHILE                WITH
  3000. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3001.  
  3002. Modula-2 keywords 
  3003.  
  3004. [hbtp] 
  3005.  
  3006. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3007.  ABS                          BITSET
  3008.  
  3009.  BOOLEAN                      CARDINAL
  3010.  
  3011.  CAP                          CHR
  3012.  
  3013.  CHAR                         COMPLEX (Complex types)
  3014.  
  3015.  CMPLX (Complex types)        DEC
  3016.  
  3017.  DISPOSE                      EXCL
  3018.  
  3019.  FALSE                        FLOAT
  3020.  
  3021.  HALT                         HIGH
  3022.  
  3023.  IM (Complex types)           INC
  3024.  
  3025.  INCL                         INT (Type conversions)
  3026.  
  3027.  INTERRUPTIBLE (Protection)   INTEGER
  3028.  
  3029.  LENGTH (Strings)             LFLOAT (Type conversions)
  3030.  
  3031.  LONGCOMPLEX (Complex types)  LONGREAL
  3032.  
  3033.  MAX                          MIN
  3034.  
  3035.  NEW                          NIL
  3036.  
  3037.  ODD                          ORD
  3038.  
  3039.  PROC                         PROTECTION (Protection)
  3040.  
  3041.  RE (Complex types)           REAL
  3042.  
  3043.  SIZE                         TRUE
  3044.  
  3045.  TRUNC                        UNINTERRUPTIBLE (Protection)
  3046.  
  3047.  VAL
  3048. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3049.  
  3050. Modula-2 pervasive identifiers 
  3051.  
  3052. [htbp] 
  3053.  
  3054. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3055.  Symbol  Meaning         Alternative
  3056.  
  3057.  [       left bracket    (!
  3058.  
  3059.  ]       right bracket   !)
  3060.  
  3061.  {       left brace      (:
  3062.  
  3063.  }       right brace     :)
  3064.  
  3065.  |       case separator  !
  3066.  
  3067.  ^       dereference     @
  3068. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3069.  
  3070. Modula-2 alternative symbols 
  3071.  
  3072.  
  3073. ΓòÉΓòÉΓòÉ 8.2.2. Complex types ΓòÉΓòÉΓòÉ
  3074.  
  3075. Types COMPLEX and LONGCOMPLEX can be used to represent complex numbers. These 
  3076. types differ in a the range and precision. The COMPLEX type is defined as a 
  3077. (REAL,REAL) pair, while LONGCOMPLEX consists of a pair of LONGREAL values. 
  3078.  
  3079. There is no notation for a complex literal. A complex value can be obtained by 
  3080. applying the standard function CMPLX to two reals. If both CMPLX arguments are 
  3081. real constants the result is the complex constant. 
  3082.  
  3083. CONST i = CMPLX(0.0,1.0);
  3084.  
  3085. If both expressions are of the REAL type, or if one is of the REAL type and the 
  3086. other is a real constant, the function returns the COMPLEX value. If both 
  3087. expressions are of the LONGREAL type, or if one is of the LONGREAL type and the 
  3088. other is a real constant the function returns the LONGCOMPLEX value. The 
  3089. following table summarizes the permitted types and the result type: 
  3090.  
  3091. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3092.                 REAL     LONGREAL     real constant
  3093.  
  3094.  REAL           REAL     error        COMPLEX
  3095.  
  3096.  LONGREAL       error    LONGCOMPLEX  LONGCOMPLEX
  3097.  
  3098.  real constant  COMPLEX  LONGCOMPLEX  complex constant
  3099. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3100.  
  3101. Standard functions RE and IM can be used to obtain a real or imaginary part of 
  3102. a value of a complex type. Both functions have one parameter. If the parameter 
  3103. is of the COMPLEX type, both functions return a REAL value; if the parameter is 
  3104. of the LONGCOMPLEX type, functions return a LONGREAL value; otherwise the 
  3105. parameter should be a complex constant and functions return a real constant. 
  3106.  
  3107. CONST one = IM(CMPLX(0.0,1.0));
  3108.  
  3109. There are four arithmetic operations for operands of a complex type: addition 
  3110. (+), subtraction (-), multiplication (*) and division (/). The following table 
  3111. indicates the result of an operation for the combinations permitted: 
  3112.  
  3113. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3114.                    COMPLEX  LONGCOMPLEX  complex constant
  3115.  
  3116.  COMPLEX           COMPLEX  error        COMPLEX
  3117.  
  3118.  LONGCOMPLEX       error    LONGCOMPLEX  LONGCOMPLEX
  3119.  
  3120.  complex constant  COMPLEX  LONGCOMPLEX  complex constant
  3121. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3122.  
  3123. There are two arithmetic monadic operations that can be applied to the values 
  3124. of a complex type: identity (+) and negation (-). The result of an operation is 
  3125. of the operand's type. 
  3126.  
  3127. Two complex comparison operators are provided for operands of complex type: 
  3128. equality and inequality. 
  3129. Example 
  3130.  
  3131. PROCEDURE abs(z: COMPLEX): REAL;
  3132. BEGIN
  3133.   RETURN RealMath.sqrt(RE(z)*RE(z)+IM(z)*IM(z))
  3134. END abs;
  3135.  
  3136.  
  3137. ΓòÉΓòÉΓòÉ 8.2.3. Sets and packedsets ΓòÉΓòÉΓòÉ
  3138.  
  3139. A set and packedset Packedset types are innovated in the standard. type defines 
  3140. a new type, whose set of values is the power set of an associated ordinal type 
  3141. called the base type of a set type. 
  3142.  
  3143. SetType       = SET OF Type;
  3144. PackedsetType = PACKEDSET OF Type;
  3145.  
  3146. The International Standard does not require a specific representation for set 
  3147. types. Packedset types have a representation that is mapped to the individual 
  3148. bits of a particular underlying architecture. The standard type BITSET is a 
  3149. pre-defined packedset type. 
  3150.  
  3151. The current XDS implementation does not distinguish between the set and 
  3152. packedset types. A set of at least 256 elements can be defined. 
  3153. Example 
  3154.  
  3155. TYPE
  3156.   CharSet = SET OF CHAR;
  3157.   LongSet = PACKEDSET OF [-127..128];
  3158.  
  3159. All set operations, such as union (+), difference (-), intersection (*), and 
  3160. symmetrical difference (/) can be applied to the values of both set and 
  3161. packedset types. 
  3162. Example 
  3163.  
  3164.    VAR letters, digits, alphanum: CharSet;
  3165.    ...
  3166.    letters  := CharSet{'a'..'z','A'..'Z'};
  3167.    digits   := CharSet{'0'..'9'};
  3168.    alphanum := letters + digits;
  3169.  
  3170.  
  3171. ΓòÉΓòÉΓòÉ 8.2.4. Strings ΓòÉΓòÉΓòÉ
  3172.  
  3173. For operands of the string literal type the string concatenation operation is 
  3174. defined, denoted by the symbol "+". Note: a character number literal (e.g. 15C) 
  3175. denotes a value of a literal string type of length 1. The empty string is 
  3176. compatible with the type CHAR and has a value equal to the string terminator 
  3177. (0C). 
  3178. Example 
  3179.  
  3180. CONST
  3181.   CR = 15C;
  3182.   LF = 12C;
  3183.   LineEnd = CR + LF;
  3184.   Greeting = "hello " + "world" + LineEnd;
  3185.  
  3186. The new standard function LENGTH can be used to obtain the length of a string 
  3187. value. 
  3188.  
  3189. PROCEDURE LENGTH(s: ARRAY OF CHAR): CARDINAL;
  3190.  
  3191.  
  3192. ΓòÉΓòÉΓòÉ 8.2.5. Value constructors ΓòÉΓòÉΓòÉ
  3193.  
  3194. A value constructor is an expression denoting a value of an array type, a 
  3195. record type, or a set type. In case of array constructors and record 
  3196. constructors a list of values, known as structure components, is specified to 
  3197. define the values of components of an array value or the fields of a record 
  3198. value. In case of a set constructor, a list of members is specified, whose 
  3199. elements define the elements of the set values. 
  3200.  
  3201. ValueConstructor = ArrayValue
  3202.                  | RecordValue
  3203.                  | SetValue.
  3204. ArrayValue = TypeIdentifier "{"
  3205.              ArrayComponent { "," ArrayComponent }
  3206.              "}".
  3207. ArrayComponent = Component [ BY RepeatCount ].
  3208. Component   = Expression.
  3209. RepeatCount = ConstExpression.
  3210. RecordValue = TypeIdentifier "{"
  3211.              Component { "," Component }
  3212.              "}".
  3213.  
  3214. Set constructors are described in PIM. 
  3215.  
  3216. The total number of components of an array constructor must be exactly the same 
  3217. as the number of array's elements (taking into account any repetition of 
  3218. components). Each component must be an assignment compatible with the array 
  3219. base type. 
  3220.  
  3221. The number of components of a record constructor must be exactly the same as 
  3222. the number of fields. Each component must be an assignment compatible with the 
  3223. type of the field. 
  3224.  
  3225. A special case is a record constructor for a record with variant parts. If the 
  3226. n-th field is the tag field the n-th component must be a constant expression. 
  3227. If there is no ELSE variant part associated with the tag field, then a variant 
  3228. associated with the value of expression should exist. If no variant is 
  3229. associated with the value, then the fields of the ELSE variant part should be 
  3230. included in the sequence of components. 
  3231.  
  3232. The constructor's components may themselves contain lists of elements, and such 
  3233. nested constructs need not specify a type identifier. This relaxation is 
  3234. necessary for multi-dimensional arrays, where the types of the inner components 
  3235. may be anonymous. 
  3236. Examples 
  3237.  
  3238. TYPE
  3239.   String = ARRAY [0..15] OF CHAR;
  3240.   Person = RECORD
  3241.     name: String;
  3242.     age : CARDINAL;
  3243.   END;
  3244.   Vector = ARRAY [0..2] OF INTEGER;
  3245.   Matrix = ARRAY [0..2] OF Vector;
  3246.  
  3247. VAR
  3248.   string: String;
  3249.   person: Person;
  3250.   vector: Vector;
  3251.   matrix: Matrix;
  3252. ....
  3253.   string:=String{" " BY 16};
  3254.   person:=Person{"Alex",32};
  3255.   vector:=Vector{1,2,3};
  3256.   matrix:=Matrix{vector,{4,5,6},Vector{7,8,9}};
  3257.   matrix:=Matrix{vector BY 3};
  3258.  
  3259.  
  3260. ΓòÉΓòÉΓòÉ 8.2.6. Multi-dimensional open arrays ΓòÉΓòÉΓòÉ
  3261.  
  3262. According to the International Standard, the parameters of a multi-dimensional 
  3263. open array are allowed. 
  3264. Example 
  3265.  
  3266. PROCEDURE Foo(VAR matrix: ARRAY OF ARRAY OF REAL);
  3267.   VAR i,j: CARDINAL;
  3268. BEGIN
  3269.   FOR i:=0 TO HIGH(matrix)
  3270.     FOR j:=0 TO HIGH(matrix[i])
  3271.       ... matrix[i,j] ...
  3272.     END;
  3273.   END;
  3274. END Foo;
  3275.  
  3276. VAR a: ARRAY [0..2],[0..2] OF REAL;
  3277.  
  3278. BEGIN
  3279.   Foo(a);
  3280. END ...
  3281.  
  3282.  
  3283. ΓòÉΓòÉΓòÉ 8.2.7. Procedure type declarations ΓòÉΓòÉΓòÉ
  3284.  
  3285. A procedure type identifier may be used in declaring of the type itself. This 
  3286. feature is used in the Standard Library. See, for example, modules ConvTypes 
  3287. and WholeConv. 
  3288. Example 
  3289.  
  3290. TYPE
  3291.   Scan = PROCEDURE (CHAR; VAR Scan);
  3292.   Func = PROCEDURE (INTEGER): Func;
  3293.  
  3294.  
  3295. ΓòÉΓòÉΓòÉ 8.2.8. Procedure constants ΓòÉΓòÉΓòÉ
  3296.  
  3297. A constant expression may contain the values of procedure types, or structured 
  3298. values whose components are the values of procedure types. Procedure constants 
  3299. may be used as a mechanism for procedure renaming. In a definition module it is 
  3300. possible to export a renamed version of imported procedure. 
  3301. Examples 
  3302.  
  3303. TYPE ProcTable = ARRAY [0..3] OF PROC;
  3304.  
  3305. CONST
  3306.   WS = STextIO.WriteString;
  3307.   Table = ProcTable{Up,Down,Left,Right};
  3308.  
  3309.  
  3310. ΓòÉΓòÉΓòÉ 8.2.9. Whole number division ΓòÉΓòÉΓòÉ
  3311.  
  3312. Along with DIV and MOD the International Standard includes two additional 
  3313. operators for whole number division: `/' and REM. 
  3314.  
  3315. Operators DIV and MOD are defined for positive divisors only, while `/' and REM 
  3316. can be used for both negative and positive divisors. 
  3317.  
  3318. The language exception wholeDivException (See Exceptions) is raised if: 
  3319.  
  3320.      second operand is zero (for all four operators) 
  3321.  
  3322.      second operand of DIV or MOD is negative. 
  3323.  
  3324.  For the given lval and rval 
  3325.  
  3326.     quotient  := lval / rval;
  3327.     remainder := lval REM rval;
  3328.  
  3329.  the following is true (for all non-zero values of rval): 
  3330.  
  3331.     
  3332.  
  3333.             lval = rval * quotient + remainder
  3334.  
  3335.      a value of remainder is either zero, or an integer of the same sign as 
  3336.       lval and of a smaller absolute value than rval. 
  3337.  
  3338.  For the given lval and rval 
  3339.  
  3340.     quotient := lval DIV rval;
  3341.     modulus  := lval MOD rval;
  3342.  
  3343.  the following is true (for all positive values of rval): 
  3344.  
  3345.     
  3346.  
  3347.             lval = rval * quotient + modules
  3348.  
  3349.      a value of modulus is a non-negative integer less than rval. 
  3350.  
  3351.  Operations are exemplified in the following table: 
  3352.  
  3353.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3354.    op   31 op 10  31 op (-10)  (-31) op 10  (-31) op (-10)
  3355.  
  3356.    /    3         -3           -3           3
  3357.  
  3358.    REM  1         1            -1           -1
  3359.  
  3360.    DIV  3         exception    -4           exception
  3361.  
  3362.    MOD  1         exception    9            exception
  3363.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3364.  
  3365.  
  3366. ΓòÉΓòÉΓòÉ 8.2.10. Type conversions ΓòÉΓòÉΓòÉ
  3367.  
  3368. The language includes the following type conversion functions: CHR, FLOAT, INT, 
  3369. LFLOAT, ORD, TRUNC and VAL. The functions INT and LFLOAT are not described in 
  3370. PIM. 
  3371.  
  3372. All the type conversion functions (except VAL) have a single parameter and can 
  3373. be expressed in terms of the VAL function. 
  3374.  
  3375. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3376.  Name    Parameter        Result    Equal to
  3377.  
  3378.  CHR     whole            CHAR      VAL(CHAR,x)
  3379.  
  3380.  FLOAT   real or whole    REAL      VAL(REAL,x)
  3381.  
  3382.  INT     real or ordinal  INTEGER   VAL(INTEGER,x)
  3383.  
  3384.  LFLOAT  real or whole    LONGREAL  VAL(LONGREAL,x)
  3385.  
  3386.  ORD     ordinal          CARDINAL  VAL(CARDINAL,x)
  3387.  
  3388.  TRUNC   real             CARDINAL  VAL(CARDINAL,x)
  3389. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3390.  
  3391. The function VAL can be used to obtain a value of a specified scalar type from 
  3392. an expression of a scalar type. The function has two parameters. The first 
  3393. parameter should be a type parameter that denotes a scalar type. If the type is 
  3394. a subrange type, the call of VAL returns the host type of the subrange type, 
  3395. otherwise it returns the type denoted by the type parameter. 
  3396.  
  3397. The second parameter should be an expression of a scalar type and at least one 
  3398. of the restriction shall hold: 
  3399.  
  3400.      the result type and the type of the expression are identical 
  3401.  
  3402.      both the result type and the type of the expression are whole or real 
  3403.  
  3404.      the result type or the type of the expression is a whole type 
  3405.  
  3406.  In the following table, ΓêÜ denotes a valid combination of types and ┬╖ denotes 
  3407.  an invalid combination: 
  3408.  
  3409.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3410.    the type of  5cthe type denoted by the type parameter
  3411.  
  3412.    expression   whole                                     real  CHAR  BOOLEAN  enumeration
  3413.  
  3414.    whole type   ΓêÜ                                         ΓêÜ     ΓêÜ     ΓêÜ        ΓêÜ
  3415.  
  3416.    real type    ΓêÜ                                         ΓêÜ     ┬╖     ┬╖        ┬╖
  3417.  
  3418.    CHAR         ΓêÜ                                         ┬╖     ΓêÜ     ┬╖        ┬╖
  3419.  
  3420.    BOOLEAN      ΓêÜ                                         ┬╖     ┬╖     ΓêÜ        ┬╖
  3421.  
  3422.    enumeration  ΓêÜ                                         ┬╖     ┬╖     ┬╖        ΓêÜ
  3423.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3424.  
  3425.  An exception is raised if the value x lies outside the range of type T in the 
  3426.  call VAL(T,x). If x is of a real type, the calls VAL(INTEGER,x) and 
  3427.  VAL(CARDINAL,x) both truncates the value of x. 
  3428.  
  3429.  
  3430. ΓòÉΓòÉΓòÉ 8.2.11. NEW and DISPOSE ΓòÉΓòÉΓòÉ
  3431.  
  3432. The standard NEW and DISPOSE procedures are back in the language. Calls of NEW 
  3433. and DISPOSE are substituted by calls of ALLOCATE and DEALLOCATE which should be 
  3434. visible in the current scope. The compiler checks the compliance of these 
  3435. substitution procedures with the expected formal type: 
  3436.  
  3437. PROCEDURE ALLOCATE(VAR a: ADDRESS; size: CARDINAL);
  3438. PROCEDURE DEALLOCATE(VAR a: ADDRESS; size: CARDINAL);
  3439.  
  3440. As a rule, the procedures ALLOCATE and DEALLOCATE declared in the module 
  3441. Storage are used. These procedures are made visible by including the import 
  3442. list: 
  3443.  
  3444. FROM Storage IMPORT ALLOCATE, DEALLOCATE;
  3445.  
  3446. When the language extensions are enabled the procedures NEW and DISPOSE can be 
  3447. applied to dynamic arrays. See NEW and DISPOSE for dynamic arrays for further 
  3448. details. 
  3449.  
  3450.  
  3451. ΓòÉΓòÉΓòÉ 8.2.12. Finalization ΓòÉΓòÉΓòÉ
  3452.  
  3453. A special mechanism called finalization is provided to perform certain 
  3454. operation during program termination. 
  3455.  
  3456. A module declaration contains an optional finalization body, which is executed 
  3457. during program termination for static modules (See Termination) or dynamic 
  3458. module finalization. 
  3459.  
  3460. ModuleBody = [ BEGIN BlockBody
  3461.              [ FINALLY BlockBody ] ] END
  3462. BlockBody  = NormalPart
  3463.              [ EXCEPT ExceptionalPart ].
  3464. NormalPart = StatementSequence.
  3465. ExceptionalPart = StatementSequence.
  3466.  
  3467. Note: a RETURN statement can be used in a BlockBody. 
  3468. Example 
  3469.  
  3470. MODULE Test;
  3471.  
  3472. ....
  3473.  
  3474. VAR cid: StreamFile.ChanId;
  3475.  
  3476. BEGIN
  3477.   StreamFile.Open(cid,"tmp",flags,res);
  3478.   Process(cid);
  3479. FINALLY
  3480.   StreamFile.Close(cid);
  3481. END Test
  3482.  
  3483. If the Test module is declared in a procedure block, then the initialization 
  3484. body will be executed on a call of the procedure, while the finalization body 
  3485. is executed after the procedure body. 
  3486.  
  3487. If the Test module is a static module, its finalization will be executed during 
  3488. the program termination. 
  3489.  
  3490. In any case the finalization bodies are executed in inverse order to their 
  3491. initializations. 
  3492.  
  3493. In the following example, a finalization of a local module is used to provide a 
  3494. correct context restoration: 
  3495.  
  3496. VAR state: State;
  3497.  
  3498. PROCEDURE Foo;
  3499.  
  3500.   MODULE AutoSave;
  3501.     IMPORT state, State;
  3502.     VAR save: State;
  3503.   BEGIN
  3504.     save:=state; (* save state *)
  3505.     state:=fooState;
  3506.   FINALLY
  3507.     state:=save; (* restore state *)
  3508.   END AutoSave;
  3509.  
  3510. BEGIN
  3511.   ... process ...
  3512. END Foo;
  3513.  
  3514. The initialization part of the AutoSave module will be executed before any 
  3515. statement in the Foo body and finalization part will be executed directly 
  3516. before ending of the call of Foo. 
  3517.  
  3518.  
  3519. ΓòÉΓòÉΓòÉ 8.2.13. Exceptions ΓòÉΓòÉΓòÉ
  3520.  
  3521. An exception handling mechanism is now included in the language. Both 
  3522. user-defined exceptions and language exceptions can be handled. There is no 
  3523. special exception type, exceptions are identified by the pair: exception source 
  3524. value and cardinal value. Two keywords (EXCEPT and RETRY) are added to the 
  3525. language. The essential part of exception handling is provided in two system 
  3526. modules: EXCEPTIONS and M2EXCEPTION. 
  3527.  
  3528. The EXCEPTIONS module provides facilities for raising and identifying the 
  3529. user-defined exceptions, for reporting their occurrence, and for making 
  3530. enquiries concerning the execution state of the current coroutine. 
  3531.  
  3532. The M2EXCEPTION module provides facilities for identifying language exceptions 
  3533. that have been raised. 
  3534.  
  3535. A procedure body, the initialization or finalization part of module body may 
  3536. contain an exceptional part. 
  3537.  
  3538. BlockBody  = NormalPart [ EXCEPT ExceptionalPart ].
  3539. NormalPart = StatementSequence.
  3540. ExceptionalPart = StatementSequence.
  3541.  
  3542. Example 
  3543.  
  3544. PROCEDURE Div(a,b: INTEGER): INTEGER;
  3545. BEGIN
  3546.   RETURN a DIV b      (* try to divide *)
  3547. EXCEPT
  3548.   RETURN MAX(INTEGER) (* if exception *)
  3549. END Fly;
  3550.  
  3551. When an exception is raised (explicitly or implicitly) the `nearest' (in terms 
  3552. of procedure calls) exceptional part in the current coroutine gets the control. 
  3553. Each coroutine is executed initially in a normal state. If an exception is 
  3554. raised, the coroutine state switches to an exceptional state. If there is no 
  3555. exceptional part, the raising of exception is a termination event (See 
  3556. Termination). 
  3557.  
  3558. A procedure with an exceptional part is executed in the normal state. The state 
  3559. is restored after the block execution. A procedure without an exceptional part 
  3560. is executed in the state of the caller. 
  3561.  
  3562. If an exception is raised in the state of exceptional execution it is re-raised 
  3563. in the calling context. In this case finalization of local modules and 
  3564. restoring protection (See Protection) will not take place. 
  3565.  
  3566. An additional statement (RETRY) can be used in the exceptional part. Execution 
  3567. of the RETRY statement causes the normal part to be re-executed in the normal 
  3568. state. 
  3569.  
  3570. Execution of the RETURN statement in the exceptional part causes switch to the 
  3571. normal state. 
  3572.  
  3573. If neither RETURN nor RETRY was executed in the exceptional part, the 
  3574. exceptional completion will occur. In this case after finalization of local 
  3575. modules (if any) and restoring protection state (if necessary), the exception 
  3576. will be re-raised. 
  3577. Example 
  3578.  
  3579. PROCEDURE Foo;
  3580. BEGIN
  3581.   TryFoo(...);
  3582. EXCEPT
  3583.   IF CanBeRepaired() THEN
  3584.     Repair;
  3585.     RETRY;  (* re-execute the normal part *)
  3586.   ELSIF CanBeProcessed() THEN
  3587.     Process;
  3588.     RETURN; (* exception is handled *)
  3589.   ELSE
  3590.     (* exception will be automatically re-raised *)
  3591.   END;
  3592. END Foo;
  3593.  
  3594.  
  3595. ΓòÉΓòÉΓòÉ 8.2.14. The system module EXCEPTIONS ΓòÉΓòÉΓòÉ
  3596.  
  3597. The module EXCEPTIONS provides facilities for raising user's exceptions and for 
  3598. making enquiries concerning the current execution state. 
  3599.  
  3600. User-defined exceptions are identified uniquely by a pair (exception source, 
  3601. number). When the source of a used-defined exception is a separate module, it 
  3602. prevents the defined exceptions of the module from being raised directly by 
  3603. other sources. See e.g. the module Storage. 
  3604.  
  3605. TYPE ExceptionSource;
  3606.  
  3607. Values of the opaque type ExceptionSource are used to identify the source of 
  3608. exceptions raised; they should be allocated before usage. 
  3609.  
  3610. TYPE ExceptionNumber = CARDINAL;
  3611.  
  3612. Values of the type ExceptionNumber are used to distinguish between different 
  3613. exceptions of one source. 
  3614.  
  3615. PROCEDURE AllocateSource(VAR newSource: ExceptionSource);
  3616.  
  3617. The procedure allocates an unique value of the type ExceptionSource. The 
  3618. procedure is normally called during initialization of the module, and the 
  3619. resulting value is then used in all calls of RAISE. If an unique value cannot 
  3620. be allocated the language exception exException is raised (See The system 
  3621. module M2EXCEPTION). 
  3622.  
  3623. PROCEDURE RAISE(source: ExceptionSource;
  3624.                 number: ExceptionNumber;
  3625.                message: ARRAY OF CHAR);
  3626.  
  3627. The procedure call associates the given values of a source, number and message 
  3628. with the current context and raises an exception. 
  3629.  
  3630. The function CurrentNumber can be used to obtain the exception number for the 
  3631. current exception. 
  3632.  
  3633. PROCEDURE CurrentNumber
  3634.    (source: ExceptionSource): ExceptionNumber;
  3635.  
  3636. If the calling coroutine is in the exceptional execution state because of 
  3637. raising an exception from source, the procedure returns the corresponding 
  3638. number, and otherwise raises an exception. 
  3639.  
  3640. The procedure GetMessage can be used to obtain the message passed when an 
  3641. exception is raised. This may give further information about the nature of the 
  3642. exception. 
  3643.  
  3644. PROCEDURE GetMessage(VAR text: ARRAY OF CHAR);
  3645.  
  3646. If the calling coroutine is in the exceptional execution state, the procedure 
  3647. returns the possibly truncated string associated with the current context. 
  3648. Otherwise, in a normal execution state, it returns the empty string. 
  3649.  
  3650. PROCEDURE IsCurrentSource
  3651.         (source: ExceptionSource): BOOLEAN;
  3652.  
  3653. If the current coroutine is in the exceptional execution state because of 
  3654. raising an exception from source, the procedure returns TRUE, and FALSE 
  3655. otherwise. 
  3656.  
  3657. PROCEDURE IsExceptionalExecution (): BOOLEAN;
  3658.  
  3659. If the current coroutine is in the exceptional execution state because of 
  3660. raising an exception, the procedure returns TRUE, and FALSE otherwise. 
  3661.  
  3662. The following example illustrates the recommended form of a library module and 
  3663. the usage of procedures from EXCEPTIONS. 
  3664.  
  3665. DEFINITION MODULE FooLib;
  3666.  
  3667. PROCEDURE Foo;
  3668. (* Raises Foo exception if necessary *)
  3669.  
  3670. PROCEDURE IsFooException(): BOOLEAN;
  3671. (* Returns TRUE, if the calling coroutine is in
  3672.    exceptional state because of the raising of
  3673.    an exception from Foo, and otherwise returns FALSE.
  3674. *)
  3675.  
  3676. END FooLib.
  3677.  
  3678. IMPLEMENTATION MODULE FooLib;
  3679.  
  3680. IMPORT EXCEPTIONS;
  3681.  
  3682. VAR source: EXCEPTIONS.ExceptionSource;
  3683.  
  3684. PROCEDURE Foo;
  3685. BEGIN
  3686.   TryFoo(...);
  3687.   IF NOT done THEN
  3688.     EXCEPTIONS.RAISE(source,0,"Foo exception");
  3689.   END;
  3690. END Foo;
  3691.  
  3692. PROCEDURE IsFooException(): BOOLEAN;
  3693. BEGIN
  3694.   RETURN EXCEPTIONS.IsCurrentSource(source)
  3695. END IsLibException;
  3696.  
  3697. BEGIN
  3698.   EXCEPTIONS.AllocateSource(source)
  3699. END FooLib.
  3700.  
  3701. If we want to distinguish the exceptions raised in the FooLib we will append an 
  3702. enumeration type and an additional enquiry procedure in the FooLib definition: 
  3703.  
  3704. TYPE FooExceptions = (fault, problem);
  3705.  
  3706. PROCEDURE FooException(): FooExceptions;
  3707.  
  3708. The FooException procedure can be implemented as follows: 
  3709.  
  3710. PROCEDURE FooException(): FooExceptions;
  3711. BEGIN
  3712.   RETURN VAL(FooExceptions,
  3713.              EXCEPTIONS.CurrentNumber(source))
  3714. END FooException;
  3715.  
  3716. The Client module illustrates the usage of a library module: 
  3717.  
  3718. MODULE Client;
  3719.  
  3720. IMPORT  FooLib, EXCEPTIONS, STextIO;
  3721.  
  3722. PROCEDURE ReportException;
  3723.   VAR s: ARRAY [0..63] OF CHAR;
  3724. BEGIN
  3725.   EXCEPTIONS.GetMessage(s);
  3726.   STextIO.WriteString(s);
  3727.   STextIO.WriteLn;
  3728. END ReportException;
  3729.  
  3730. PROCEDURE TryFoo;
  3731. BEGIN
  3732.   FooLib.Foo;
  3733. EXCEPT
  3734.   IF FooLib.IsFooException() THEN
  3735.     ReportException;
  3736.     RETURN; (* exception is handled *)
  3737.   ELSE
  3738.     (* Exception will be re-raised *)
  3739.   END
  3740. END TryFoo;
  3741.  
  3742. END Client.
  3743.  
  3744.  
  3745. ΓòÉΓòÉΓòÉ 8.2.15. The system module M2EXCEPTION ΓòÉΓòÉΓòÉ
  3746.  
  3747. The system module M2EXCEPTION provides facilities for identifying language 
  3748. exceptions. The language (which includes the system modules) is regarded as one 
  3749. source of exceptions. 
  3750.  
  3751. The module provides the enumeration type in terms of which the language 
  3752. exceptions are raised and two enquiry functions. 
  3753.  
  3754. TYPE
  3755.   M2Exceptions =
  3756.     (indexException,      rangeException,
  3757.      caseSelectException, invalidLocation,
  3758.      functionException,   wholeValueException,
  3759.      wholeDivException,   realValueException,
  3760.      realDivException,    complexValueException,
  3761.      complexDivException, protException,
  3762.      sysException,        coException,
  3763.      exException
  3764.     );
  3765.  
  3766. PROCEDURE IsM2Exception(): BOOLEAN;
  3767.  
  3768. If the current coroutine is in the exceptional execution state because of 
  3769. raising a language exception, the procedure returns TRUE, and FALSE otherwise. 
  3770.  
  3771. PROCEDURE M2Exception(): M2Exceptions;
  3772.  
  3773. If the current coroutine is in the exceptional execution state because of 
  3774. raising a language exception, the procedure returns the corresponding 
  3775. enumeration value, and otherwise raises an exception. 
  3776.  
  3777. The following description lists all language exceptions (in an alphabetical 
  3778. order) along with the circumstances in which exceptions are detected. Note: 
  3779. Compiler options can be used to control the detection of some exceptions (See 
  3780. Chapter Compiler Options and Equations). Detection of some exceptions is not 
  3781. required, however such exceptions can be detected on some platforms (See 
  3782. Chapter Implementation limitations and restrictions). 
  3783.  
  3784.  caseSelectException 
  3785.  
  3786.            Case selector is out of range and the ELSE clause does not exist. 
  3787.  
  3788.  coException 
  3789.  
  3790.            The system module COROUTINES exceptions: 
  3791.  
  3792.                RETURN from coroutine other than the main coroutine 
  3793.  
  3794.                size of the supplied workspace smaller than the minimum 
  3795.                 required (See NEWCOROUTINE) 
  3796.  
  3797.                the caller is not attached to the source of interrupts (See 
  3798.                 HANDLER) 
  3799.  
  3800.                coroutine workspace overflow 
  3801.  
  3802.  complexDivException 
  3803.  
  3804.            Divide by zero in a COMPLEX expression. 
  3805.  
  3806.  complexValueException 
  3807.  
  3808.            Overflow in evaluation of a COMPLEX expression. 
  3809.  
  3810.  exException 
  3811.  
  3812.            The system modules EXCEPTIONS and M2EXCEPTION exception: 
  3813.  
  3814.                exception identity is enquiry in normal execution (See 
  3815.                 CurrentNumber) 
  3816.  
  3817.                exception identity enquiry to a wrong source (SeeCurrentNumber) 
  3818.  
  3819.                no further exception source values can be allocated (See 
  3820.                 AllocateSource) 
  3821.  
  3822.  functionException 
  3823.  
  3824.            No RETURN statement before the end of a function. 
  3825.  
  3826.  indexException 
  3827.  
  3828.            Array indexed out of range. See options CHECKINDEX and CHECKDINDEX. 
  3829.  
  3830.  invalidLocation 
  3831.  
  3832.            Attempt to dereference NIL or uninitialized pointer. See the option 
  3833.            CHECKNIL. 
  3834.  
  3835.  protException 
  3836.  
  3837.            Given protection is less restrictive than the current protection. 
  3838.  
  3839.  rangeException 
  3840.  
  3841.            Range exception (See the CHECKRANGE option): 
  3842.  
  3843.                assignment value is out of range of a target 
  3844.  
  3845.                structure component value is out of range 
  3846.  
  3847.                expression cannot be converted to a new type 
  3848.  
  3849.                value to be included/excluded is not of the base type of a set 
  3850.                 (See also the CHECKSET option) 
  3851.  
  3852.                return value is out of range 
  3853.  
  3854.                set value is out of range (See also the CHECKSET option) 
  3855.  
  3856.                tag value is out of range (in a variant record). 
  3857.  
  3858.  realDivException 
  3859.  
  3860.            Divide by zero in a REAL expression. 
  3861.  
  3862.  realValueException 
  3863.  
  3864.            Overflow in evaluation of a REAL expression. 
  3865.  
  3866.  sysException 
  3867.  
  3868.            The system module SYSTEM exceptions. Note: All these exceptions are 
  3869.            non-mandatory. 
  3870.  
  3871.                invalid use of ADDADR, SUBADR or DIFADR 
  3872.  
  3873.                the result of MAKEADR is out of the address range 
  3874.  
  3875.                alignment problem with CAST 
  3876.  
  3877.                the result of CAST is not a valid representation for the target 
  3878.                 type 
  3879.  
  3880.  wholeDivException 
  3881.  
  3882.            Whole division exception: 
  3883.  
  3884.                divided by zero in evaluation of a whole number expression 
  3885.  
  3886.                the second operand of DIV or MOD is negative (See the CHECKDIV 
  3887.                 option) 
  3888.  
  3889.  wholeValueException 
  3890.  
  3891.            Overflow in evaluation of a whole number expression. 
  3892.  
  3893.  Example of handling a language exception 
  3894.  
  3895.   PROCEDURE Div(a,b: INTEGER): INTEGER;
  3896.   BEGIN
  3897.     RETURN a DIV b
  3898.   EXCEPT
  3899.     IF IsM2Exception() THEN
  3900.       IF M2Exception() = wholeDivException THEN
  3901.         IF a < 0 THEN RETURN MIN(INTEGER)
  3902.         ELSE          RETURN MAX(INTEGER)
  3903.         END;
  3904.       END;
  3905.     END;
  3906.   END Div;
  3907.  
  3908.  
  3909. ΓòÉΓòÉΓòÉ 8.2.16. Termination ΓòÉΓòÉΓòÉ
  3910.  
  3911. During the program termination, finalization of those static modules that have 
  3912. started initialization are executed in inverse order their initialization (See 
  3913. also Finalization). The static modules are the program module, the 
  3914. implementation modules, and any local modules declared in the module blocks of 
  3915. these modules. 
  3916.  
  3917. Program termination starts from the first occurrence of the following event: 
  3918.  
  3919.    1. the end of the program module body is reached 
  3920.  
  3921.    2. a RETURN statement is executed in the program module body 
  3922.  
  3923.    3. the standard procedure HALT is called 
  3924.  
  3925.    4. an exception is raised and this exception is not handled. 
  3926.  
  3927.  The system module TERMINATION provides facilities for enquiries concerning the 
  3928.  occurrence of termination events. 
  3929.  
  3930.   PROCEDURE IsTerminating(): BOOLEAN;
  3931.  
  3932.  Returns TRUE if any coroutine has started the program termination and FALSE 
  3933.  otherwise. 
  3934.  
  3935.   PROCEDURE HasHalted(): BOOLEAN;
  3936.  
  3937.  Returns TRUE if a call of HALT has been made and FALSE otherwise. 
  3938.  
  3939.  
  3940. ΓòÉΓòÉΓòÉ 8.2.17. Coroutines ΓòÉΓòÉΓòÉ
  3941.  
  3942. The system module COROUTINES provides facilities for creating coroutines, for 
  3943. the explicit transfer of control between coroutines, and for handling of the 
  3944. interrupts. Note: Some features can be unavailable in the current release. See 
  3945. Chapter Implementation limitations and restrictions for details. 
  3946.  
  3947. Values of the type COROUTINE are created dynamically by a call of NEWCOROUTINE 
  3948. and identify the coroutine in subsequent operations. A particular coroutine is 
  3949. identified by the same value of the coroutine type throughout the lifetime of 
  3950. that coroutine. 
  3951.  
  3952. TYPE COROUTINE;
  3953.  
  3954. The correspondent type was called PROCESS in PIM. From the third edition of 
  3955. PIM, the ADDRESS type was used to identify a coroutine. 
  3956.  
  3957. PROCEDURE NEWCOROUTINE(
  3958.                 procBody: PROC;
  3959.                 workspace: SYSTEM.ADDRESS;
  3960.                 size: CARDINAL;
  3961.                 VAR cr: COROUTINE
  3962.                 [; initProtection: PROTECTION]);
  3963.  
  3964. Creates a new coroutine whose body is given by procBody, and returns the 
  3965. identity of the coroutine in cr. workspace is a pointer to the work space 
  3966. allocated to the coroutine; size specifies the size of this workspace in terms 
  3967. of SYSTEM.LOC. initProtection is an optional parameter that specifies the 
  3968. initial protection level of the coroutine. 
  3969.  
  3970. An exception is raised (See coException) if the value of size is less than the 
  3971. minimum workspace size. 
  3972.  
  3973. If the optional parameter is omitted, the initial protection of the coroutine 
  3974. is given by the current protection of the caller. 
  3975.  
  3976. The created coroutine is initialized in such a way that when control is first 
  3977. transferred to that coroutine, the procedure given by procBody is called in a 
  3978. normal state. The exception (coException) is raised when the procBody procedure 
  3979. attempts to return to its caller. Since the caller has no exception handler, 
  3980. raising this exception is a termination event. 
  3981.  
  3982. The procedure TRANSFER can be used to transfer control from one coroutine to 
  3983. another. 
  3984.  
  3985. PROCEDURE TRANSFER (VAR from: COROUTINE; to: COROUTINE);
  3986.  
  3987. Returns the identity of the calling coroutine in from and transfers control to 
  3988. the coroutine specified by to. 
  3989.  
  3990. PROCEDURE CURRENT (): COROUTINE;
  3991.  
  3992. Returns the identity of the calling coroutine. 
  3993.  
  3994.      Interrupt handling 
  3995.      Protection 
  3996.  
  3997.  
  3998. ΓòÉΓòÉΓòÉ 8.2.17.1. Interrupt handling ΓòÉΓòÉΓòÉ
  3999.  
  4000. The INTERRUPTSOURCE type is used to identify interrupts. 
  4001.  
  4002. TYPE INTERRUPTSOURCE = INTEGER;
  4003.  
  4004. Programs that use the interrupt handling facilities may be non-portable since 
  4005. the type is implementation-defined. 
  4006.  
  4007. PROCEDURE ATTACH(source: INTERRUPTSOURCE);
  4008.  
  4009. Associates the specified source of interrupts with the calling coroutine. More 
  4010. than one source of interrupts may be associated with a single coroutine. 
  4011.  
  4012. PROCEDURE DETACH(source: INTERRUPTSOURCE);
  4013.  
  4014. Dissociates the specified source of interrupts from the calling coroutine. The 
  4015. call has no effect if the coroutine is not associated with source. 
  4016.  
  4017. PROCEDURE IsATTACHED(source: INTERRUPTSOURCE): BOOLEAN;
  4018.  
  4019. Returns TRUE if and only if the specified source of interrupts is currently 
  4020. associated with a coroutine; otherwise returns FALSE. 
  4021.  
  4022. PROCEDURE HANDLER(source: INTERRUPTSOURCE): COROUTINE;
  4023.  
  4024. Returns the coroutine, if any, that is associated with the source of 
  4025. interrupts. The result is undefined if there is no coroutine associated with 
  4026. the source. 
  4027.  
  4028. PROCEDURE IOTRANSFER(VAR from: COROUTINE;
  4029.                            to: COROUTINE);
  4030.  
  4031. Returns the identity of the calling coroutine in from and transfers control to 
  4032. the coroutine specified by to. On occurrence of an interrupt, associated with 
  4033. the caller, control is transferred back to the caller, and from returns the 
  4034. identity of the interrupted coroutine. An exception is raised if the calling 
  4035. coroutine is not associated with a source of interrupts. 
  4036.  
  4037.  
  4038. ΓòÉΓòÉΓòÉ 8.2.17.2. Protection ΓòÉΓòÉΓòÉ
  4039.  
  4040. See section Protection for information about PROTECTION type. 
  4041.  
  4042. PROCEDURE LISTEN(prot: PROTECTION);
  4043.  
  4044. Momentarily changes protection of the calling coroutine to prot, usually 
  4045. lowering it so as to allow an interrupt request to be granted. 
  4046.  
  4047. PROCEDURE PROT(): PROTECTION;
  4048.  
  4049. Returns protection of the calling coroutine. 
  4050.  
  4051.  
  4052. ΓòÉΓòÉΓòÉ 8.2.18. Protection ΓòÉΓòÉΓòÉ
  4053.  
  4054. A program module, implementation module or local module may specify, by 
  4055. including protection in its heading, that execution of the enclosed statement 
  4056. sequence is protected. 
  4057.  
  4058. ModuleHeading = MODULE ident [ Protection ] ";".
  4059. Protection    = [ ConstExpression ].
  4060.  
  4061. A module with protection in its heading is called a directly protected module. 
  4062. A directly protected procedure is an exported procedure declared in the 
  4063. protected module. 
  4064.  
  4065. Protection of a module is provided by surrounding the externally accessible 
  4066. procedures and module body by calls of access control procedures. The value of 
  4067. the protection expression is passed to the call of access control procedures as 
  4068. an actual parameter. 
  4069.  
  4070. The protection expression should be of the PROTECTION type. The PROTECTION type 
  4071. is an elementary type with at least two values: INTERRUPTIBLE and 
  4072. UNINTERRUPTIBLE. 
  4073.  
  4074. Operators <, >, <= and >= can be used to compare the values of the PROTECTION 
  4075. type. If x is a value of PROTECTION type, then x satisfies the conditions: 
  4076.  
  4077.  UNINTERRUPTIBLE ?x? INTERRUPTIBLE 
  4078.  
  4079.  
  4080. ΓòÉΓòÉΓòÉ 8.3. Standard procedures ΓòÉΓòÉΓòÉ
  4081.  
  4082. [hbt] 
  4083.  
  4084. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4085.      Procedure      Meaning
  4086.  
  4087.  ΓêÜ   ASSERT(x[,n])  Terminates program if x?TRUE (See ASSERT)
  4088.  
  4089.      COPY(x,v)      Copy string: v := x
  4090.  ΓêÜ
  4091.  
  4092.      DEC(v[,n])     v := v - n, default n=1
  4093.  
  4094.      DISPOSE(v)     Deallocates v^(See NEW and DISPOSE)
  4095.  
  4096.      EXCL(v,n)      v := v - {n}
  4097.  
  4098.      HALT           Terminates program execution (See HALT)
  4099.  
  4100.      INC(v[,n])     v := v + n, default n=1
  4101.  
  4102.      INCL(v,n)      v := v + {n}
  4103.  
  4104.      NEW(v)         Allocates v^(See NEW and DISPOSE)
  4105.  
  4106.  ΓêÜ   NEW(v,x0xn)    Allocates v^of length x0xn (See NEW and DISPOSE for dynamic arrays)
  4107. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4108.  
  4109. Modula-2 proper procedures 
  4110.  
  4111. [htb] 
  4112.  
  4113. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4114.    Function    Meaning
  4115.  
  4116.    ABS(x)      Absolute value of x
  4117.  
  4118.  ΓêÜ ASH(x,n)    Arithmetic shift
  4119.  
  4120.    CAP(x)      Corresponding capital letter
  4121.  
  4122.    CHR(x)      Character with an ordinal number x
  4123.  
  4124.    CMPLX(x,y)  Complex number with real part x and imaginary part y
  4125.  
  4126.  ΓêÜ ENTIER(x)   Largest integer not greater than x
  4127.  
  4128.    FLOAT(x)    VAL(REAL,x)
  4129.  
  4130.    HIGH(v)     High bound of the index of v
  4131.  
  4132.    IM(x)       Imaginary part of a complex x
  4133.  
  4134.    INT(x)      VAL(INTEGER,x)
  4135.  
  4136.  ΓêÜ LEN(v[,n])  Length of an array in the dimension n (default=0)
  4137.  
  4138.    LENGTH(x)   String length
  4139.  
  4140.    LFLOAT(x)   VAL(LONGREAL,x)
  4141.  
  4142.    MAX(T)      Maximum value of type T
  4143.  
  4144.    MIN(T)      Minimum value of type T
  4145.  
  4146.    ODD(x)      x MOD 2 = 1
  4147.  
  4148.    ORD(x)      VAL(CARDINAL,x)
  4149.  
  4150.    RE(x)       Real part of a complex x
  4151.  
  4152.    SIZE(T)     The number of storage units, required by a variable of type T
  4153.  
  4154.    TRUNC(x)    Truncation to the integral part
  4155.  
  4156.    VAL(T,x)    Type conversion
  4157. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4158.  
  4159. Modula-2 function procedures 
  4160.  
  4161. This section is intended for a brief description of the set of standard 
  4162. procedures and functions. Some of the procedures and functions are not 
  4163. described in the International Standard and are available only if the option 
  4164. M2EXTENSIONS is set. The procedure HALT may have an additional parameter, if 
  4165. the extensions are enabled (See HALT). 
  4166.  
  4167. In the tables (Standard procedures and Standard procedures) of predefined 
  4168. procedures, v means a designator, x, y and n mean an expression, T means a 
  4169. type. Non-standard procedures are marked with ΓêÜ. 
  4170.  
  4171. The procedure COPY and the functions ASH, ENTIER and LEN are described in the 
  4172. Oberon-2 report 
  4173.  
  4174.  
  4175. ΓòÉΓòÉΓòÉ 8.4. Compatibility ΓòÉΓòÉΓòÉ
  4176.  
  4177. This section describes compatibility between entities of different types. There 
  4178. are three forms of compatibility: 
  4179.  
  4180.      expression compatibility (specifying the types that may be combined in 
  4181.       expressions); 
  4182.  
  4183.      assignment compatibility (specifying the type of a value that may be 
  4184.       assigned to a variable); 
  4185.  
  4186.      parameter compatibility (specifying the type of an actual parameter that 
  4187.       may be passed to a formal parameter). 
  4188.  
  4189.  The rules for parameter compatibility are relaxed in the case where a formal 
  4190.  parameter is of a system storage type. This variation is known as the system 
  4191.  parameter compatibility. 
  4192.  
  4193.  In most cases the compatibility rules are the same as described in PIM. 
  4194.  However, we suppose to explicitly list all the rules. 
  4195.  
  4196.      Expression compatibility 
  4197.      Assignment compatibility 
  4198.      Value parameter compatibility 
  4199.      Variable parameter compatibility 
  4200.      System parameter compatibility 
  4201.  
  4202.  
  4203. ΓòÉΓòÉΓòÉ 8.4.1. Expression compatibility ΓòÉΓòÉΓòÉ
  4204.  
  4205. Two expressions a and b of types Ta and Tb are expression compatible if any of 
  4206. the following statement is true: 
  4207.  
  4208.    1. The types Ta and Tb are identical. Note: If a type is a subrange type, 
  4209.       then only its host type matters, therefore values of subranges of the 
  4210.       same host type are expression compatible with each other and with the 
  4211.       host type. 
  4212.  
  4213.    2. A type of one expression is a complex type, and the other expression is a 
  4214.       complex constant. 
  4215.  
  4216.    3. A type of one expression is a real type, and the other expression is a 
  4217.       real constant. 
  4218.  
  4219.    4. A type of one expression is a whole type, and the other expression is a 
  4220.       whole constant. 
  4221.  
  4222.    5. A type of one expression is character, and the other expression is a 
  4223.       string literal of length 0 or 1. See also Strings. 
  4224.  
  4225.             VAR
  4226.               char: CHAR;
  4227.               ...
  4228.               WHILE (char # '') & (char # ".") DO
  4229.               ...
  4230.  
  4231.  
  4232. ΓòÉΓòÉΓòÉ 8.4.2. Assignment compatibility ΓòÉΓòÉΓòÉ
  4233.  
  4234. An expression e of type Te is assignment compatible with the variable v of type 
  4235. Tv if one of the following conditions holds For an expression of a subrange 
  4236. type only host type matters. : 
  4237.  
  4238.    1. Tv is identical to the type Te, and the type is not an open array type. 
  4239.  
  4240.    2. Tv is a subrange of the type Te. 
  4241.  
  4242.    3. Tv is the CARDINAL type or a subrange of the CARDINAL type and Te is the 
  4243.       INTEGER type or e is a whole constant. 
  4244.  
  4245.    4. Tv is the INTEGER type or a subrange of the INTEGER type and Te is the 
  4246.       CARDINAL type or e is a whole constant. 
  4247.  
  4248.    5. Tv is a real type and e is a real constant. 
  4249.  
  4250.    6. Tv is a complex type and e is a complex constant. 
  4251.  
  4252.    7. Tv is a pointer type and e is NIL. 
  4253.  
  4254.    8. Tv is a procedure type and e is the designator of a procedure which has 
  4255.       the same structure as the procedure type Tv and which has been declared 
  4256.       at level 0. 
  4257.  
  4258.    9. Tv is the character type or a subrange of the character type and e is a 
  4259.       string literal of length 0 or 1. 
  4260.  
  4261.   10. Tv is an array type having the character type as its component type, and 
  4262.       e is a string literal of length less then or equal to the number of 
  4263.       components in arrays of type TvA string literal is not assignment 
  4264.       compatible with an array whose component's type is a subrange of the 
  4265.       character type.. 
  4266.  
  4267.   11. Tv is the address type and Te is a pointer type or Te is the address type 
  4268.       and Tv is a pointer type. 
  4269.  
  4270.  
  4271. ΓòÉΓòÉΓòÉ 8.4.3. Value parameter compatibility ΓòÉΓòÉΓòÉ
  4272.  
  4273. A formal type is value parameter compatible with an actual expression if any of 
  4274. the following statements is true: 
  4275.  
  4276.    1. The formal type is constructed from a system storage type and is system 
  4277.       parameter compatible with the expression. 
  4278.  
  4279.    2. The formal parameter is an open array, the actual parameter is an array 
  4280.       type and the component type of the formal type is value parameter 
  4281.       compatible with the component type of the actual type A formal array 
  4282.       parameter with the component's type T is not parameter compatible with 
  4283.       the actual parameter of type T.. 
  4284.  
  4285.    3. The formal type is assignment compatible with the actual parameter. 
  4286.  
  4287.  
  4288. ΓòÉΓòÉΓòÉ 8.4.4. Variable parameter compatibility ΓòÉΓòÉΓòÉ
  4289.  
  4290. A formal type is variable parameter compatible with an actual variable if any 
  4291. of the following statements is true: 
  4292.  
  4293.    1. The formal type is constructed from a system storage type and is system 
  4294.       parameter compatible with the expression. 
  4295.  
  4296.    2. The formal parameter is an open array, the actual parameter is an array 
  4297.       type and the component's type of the formal type is variable parameter 
  4298.       compatible with the component's type of the actual parameter type. 
  4299.  
  4300.    3. The formal type is identical to the actual parameter type. 
  4301.  
  4302.  
  4303. ΓòÉΓòÉΓòÉ 8.4.5. System parameter compatibility ΓòÉΓòÉΓòÉ
  4304.  
  4305. A formal type is system parameter compatible with an actual parameter if any of 
  4306. the following statements is true: 
  4307.  
  4308.    1. The formal parameter is of the SYSTEM.LOC type and the actual parameter 
  4309.       is of any type T such that SIZE(T) is equal to 1. 
  4310.  
  4311.    2. The formal parameter is of the type 
  4312.  
  4313.             ARRAY [0..n-1] OF SYSTEM.LOC
  4314.  
  4315.       and the actual parameter is of any type T such that SIZE(T) is equal to 
  4316.       n. 
  4317.  
  4318.    3. The formal parameter is of the open array type 
  4319.  
  4320.             ARRAY OF SYSTEM.LOC
  4321.  
  4322.       and the actual parameter is of any type but not numeric literal. 
  4323.  
  4324.    4. The formal parameter is of the multi-dimensional open array type 
  4325.  
  4326.             ARRAY OF ARRAY [0..n-1] OF SYSTEM.LOC
  4327.  
  4328.       and the actual parameter is of any type T such that SIZE(T) is a multiple 
  4329.       of n. 
  4330.  
  4331.  
  4332. ΓòÉΓòÉΓòÉ 8.5. The module SYSTEM ΓòÉΓòÉΓòÉ
  4333.  
  4334. The module SYSTEM provides the low-level facilities for gaining an access to 
  4335. the address and underlying storage of variables, performing address arithmetic 
  4336. operations and manipulating the representation of values. Program that use 
  4337. these facilities may be non-portable. 
  4338.  
  4339. This module does not exist in the same sense as other libraries but is 
  4340. hard-coded into the compiler itself. To use the facilities provided, however, 
  4341. identifiers must be imported in a usual way. 
  4342.  
  4343. Some of the SYSTEM module procedures are generic procedures that cannot be 
  4344. explicitly declared, i.e. they apply to classes of operand types or have 
  4345. several possible forms of a parameter list . 
  4346.  
  4347. The SYSTEM module is the only module specified in the International Standard 
  4348. that can be extended in the implementation. The XDS SYSTEM module provides 
  4349. additional types and procedures. 
  4350.  
  4351. DEFINITION MODULE SYSTEM;
  4352.  
  4353. CONST
  4354.   BITSPERLOC  = 8;
  4355.   LOCSPERWORD = 4;
  4356.   LOCSPERBYTE = 1;
  4357.  
  4358. TYPE
  4359.   LOC;
  4360.   ADDRESS = POINTER TO LOC;
  4361.   WORD = ARRAY [0 .. LOCSPERWORD-1] OF LOC;
  4362.   BYTE = LOC;
  4363.  
  4364. PROCEDURE ADDADR(addr: ADDRESS; offset: CARDINAL): ADDRESS;
  4365. PROCEDURE SUBADR(addr: ADDRESS; offset: CARDINAL): ADDRESS;
  4366. PROCEDURE DIFADR(addr1, addr2: ADDRESS): INTEGER;
  4367.  
  4368. PROCEDURE MAKEADR(val: <whole type>): ADDRESS;
  4369.  
  4370. PROCEDURE ADR(VAR v: <anytype>): ADDRESS;
  4371.  
  4372. PROCEDURE REF(VAR v: <anytype>): POINTER TO <type of the parameter>;
  4373.  
  4374. PROCEDURE ROTATE(val: <a packedset type>;
  4375.                  num: INTEGER): <type of the first parameter>;
  4376.  
  4377. PROCEDURE SHIFT(val: <a packedset type>;
  4378.                 num: INTEGER): <type of the first parameter>;
  4379.  
  4380. PROCEDURE CAST(<targettype>;
  4381.                val: <anytype>): <targettype>;
  4382.  
  4383. PROCEDURE TSIZE (<type>; ... ): CARDINAL;
  4384.  
  4385. (*------------------------------------------------------- *)
  4386. (* -------------- non-standard features ----------------- *)
  4387.  
  4388. TYPE
  4389.   INT8   = <integer 8-bits type>;
  4390.   INT16  = <integer 16-bits type>;
  4391.   INT32  = <integer 32-bits type>;
  4392.   CARD8  = <cardinal 8-bits type>;
  4393.   CARD16 = <cardinal 16-bits type>;
  4394.   CARD32 = <cardinal 32-bits type>;
  4395.   BOOL8  = <boolean 8-bits type>;
  4396.   BOOL32 = <boolean 32-bits type>;
  4397.   INDEX  = <type of index>
  4398.   DIFADR_TYPE = <type that DIFADR function returns>
  4399.  
  4400. TYPE (* for use in Oberon *)
  4401.   INT  = <Modula-2 INTEGER type>;
  4402.   CARD = <Modula-2 CARDINAL type>;
  4403.  
  4404. TYPE (* for interfacing to C *)
  4405.   int      = <C int type>;
  4406.   unsigned = <C unsigned type>;
  4407.   size_t   = <C size_t type>;
  4408.   void     = <C void type>;
  4409.  
  4410. PROCEDURE MOVE(src,dest: ADDRESS; size: CARDINAL);
  4411.  
  4412. PROCEDURE GET(adr: ADDRESS; VAR var: SimpleType);
  4413. PROCEDURE PUT(adr: ADDRESS; var: SimpleType);
  4414.  
  4415. PROCEDURE CC(n: CARDINAL): BOOLEAN;
  4416.  
  4417. END SYSTEM.
  4418.  
  4419.      System types 
  4420.      System functions 
  4421.      System procedures 
  4422.  
  4423.  
  4424. ΓòÉΓòÉΓòÉ 8.5.1. System types ΓòÉΓòÉΓòÉ
  4425.  
  4426.  LOC 
  4427.  
  4428.            Values of the LOC type are the uninterpreted contents of the 
  4429.            smallest addressable unit of a storage in implementation. The value 
  4430.            of the call TSIZE(LOC) is therefore equal to one. 
  4431.  
  4432.            The type LOC was introduced as a mechanism to resolve the problems 
  4433.            with BYTE and WORD types. Its introduction allows a consistent 
  4434.            handling of both these types, and enables also WORD-like types to be 
  4435.            further introduced, eg: 
  4436.  
  4437.                       TYPE WORD16 = ARRAY [0..1] OF SYSTEM.LOC;
  4438.  
  4439.            The only operation directly defined for the LOC type is an 
  4440.            assignment. There are special rules affecting parameter 
  4441.            compatibility for system storage types. See System parameter 
  4442.            compatibility for further details. 
  4443.  
  4444.  BYTE 
  4445.  
  4446.            BYTE is defined as LOC and has all the properties of the type LOC. 
  4447.  
  4448.  WORD 
  4449.  
  4450.            The type WORD is defined as 
  4451.  
  4452.                       CONST LOCSPERWORD = 4;
  4453.                       TYPE WORD = ARRAY [0..LOCSPERWORD-1] OF LOC;
  4454.  
  4455.            and the value of the call TSIZE(WORD) is equal to LOCSPERWORD. 
  4456.  
  4457.            The only operation directly defined for the WORD type is an 
  4458.            assignment. There are special rules affecting parameter 
  4459.            compatibility for system storage types. See System parameter 
  4460.            compatibility for further details. 
  4461.  
  4462.  ADDRESS 
  4463.  
  4464.            The type ADDRESS is defined as 
  4465.  
  4466.                         TYPE ADDRESS = POINTER TO LOC;
  4467.  
  4468.            The ADDRESS type is an assignment compatible with all pointer types 
  4469.            and vice versa (See Assignment compatibility). A formal variable 
  4470.            parameter of the ADDRESS type is a parameter compatible with an 
  4471.            actual parameter of any pointer type. 
  4472.  
  4473.            Variables of type ADDRESS are no longer expression compatible with 
  4474.            CARDINAL (as was in PIM) and they cannot directly occur in 
  4475.            expressions that include arithmetic operators. Functions ADDADR, 
  4476.            SUBADR and DIFADR were introduced for address arithmetic. 
  4477.  
  4478.  Whole system types 
  4479.  
  4480.            Types INT8, CARD8, INT16, CARD16, INT32, CARD32 are guaranteed to 
  4481.            contain 8, 16, or 32 bits respectively. 
  4482.  
  4483.            These types are introduced to simplify constructing the interfaces 
  4484.            for foreign libraries (See Chapter Multilanguage programming). Types 
  4485.            SHORTINT, LONGINT, SHORTCARD, LONGCARD are synonyms of INT8, INT32, 
  4486.            CARD8, CARD32, respectively (See also the M2ADDTYPES option). Types 
  4487.            INTEGER and CARDINAL are synonyms of INT16/INT32, CARD16/CARD32, 
  4488.            depending on the platform. 
  4489.  
  4490.            These types are not described in the International Standard. 
  4491.  
  4492.  Boolean system types 
  4493.  
  4494.            Types BOOL8 and BOOL32 are guaranteed to contain 8 and 32 bits 
  4495.            respectively. By default the compiler uses BOOL8 type for BOOLEAN. 
  4496.            In some cases (e.g. in interface to OS/2 or Windows API) BOOL32 
  4497.            should be used instead (See also the option M2UNPACKTYPES). 
  4498.  
  4499.  Modula-2 whole types 
  4500.  
  4501.            Types INT and CARD are equal to Modula-2 INTEGER and CARDINAL types, 
  4502.            respectively. These types can be used in Oberon-2 in order to use 
  4503.            Modula-2 procedures in portable way. See Modula-2 and Oberon-2 for 
  4504.            further details. 
  4505.  
  4506.  Interface to C 
  4507.  
  4508.            Types int, unsigned, size_t and void are introduced to simplify 
  4509.            constructing the interfaces to C libraries. See Interfacing to C for 
  4510.            further details. 
  4511.  
  4512.  
  4513. ΓòÉΓòÉΓòÉ 8.5.2. System functions ΓòÉΓòÉΓòÉ
  4514.  
  4515. PROCEDURE ADDADR(addr: ADDRESS;
  4516.                  offs: CARDINAL): ADDRESS;
  4517.  
  4518. Returns an address given by (addr + offs). The subsequent use of the calculated 
  4519. address may raise an exception. 
  4520.  
  4521. PROCEDURE SUBADR(addr: ADDRESS;
  4522.                  offs: CARDINAL): ADDRESS;
  4523.  
  4524. Returns an address given by (addr - offs). The subsequent use of the calculated 
  4525. address may raise an exception. 
  4526.  
  4527. PROCEDURE DIFADR(addr1,addr2: ADDRESS): INTEGER;
  4528.  
  4529. Returns the difference between addresses (addr1 - addr2). 
  4530.  
  4531. PROCEDURE MAKEADR(val: <whole type>): ADDRESS;
  4532.  
  4533. The function is used to construct a value of the ADDRESS type from the value of 
  4534. a whole typeThe International Standard does not define the number and types of 
  4535. the parameters. Programs that use this procedure may be non-portable.. 
  4536.  
  4537. PROCEDURE ADR(VAR v: <any type>): ADDRESS;
  4538.  
  4539. Returns the address of the variable v. 
  4540.  
  4541. PROCEDURE REF(VAR v: <anytype>): POINTER TO <type of the parameter>;
  4542.  
  4543. Returns the pointer to the variable v. See also Parameter compatibility. 
  4544.  
  4545. PROCEDURE CAST(<type>; x: <any type>): <type>;
  4546.  
  4547. The function CAST can be used (as a type transfer function) to interpret a 
  4548. value of any type other than a numeric literal value as a value of another type 
  4549. The International Standard forbids the use of the PIM style type transfer, like 
  4550. CARDINAL(x).. 
  4551.  
  4552. The value of the call CAST(Type,val) is an unchecked conversion of val to the 
  4553. type Type. If SIZE(val) = TSIZE(Type), the bit pattern representation of the 
  4554. result is the same as the bit pattern representation of val; otherwise the 
  4555. result and the value of val have the same bit pattern representation for a size 
  4556. equal to the smaller of the numbers of storage units. 
  4557.  
  4558. The given implementation may forbid some combinations of parameter types. 
  4559.  
  4560. PROCEDURE TSIZE(Type; ... ): CARDINAL;
  4561.  
  4562. Returns the number of storage units (LOCS) used to store the value of the 
  4563. specified type. The extra parameters, if present, are used to distinguish 
  4564. variants in a variant record and must be constant expressionsThose constant 
  4565. expressions are ignored in the current release.. 
  4566. Example 
  4567.  
  4568. TYPE
  4569.   R = RECORD
  4570.     CASE i: INTEGER OF
  4571.       |1: r: REAL;
  4572.       |2: b: BOOLEAN;
  4573.     END;
  4574.   END;
  4575.  
  4576.   ... TSIZE(R,1) ...
  4577.  
  4578. The value of TSIZE(T) is equal to SIZE(T). 
  4579.  
  4580.  
  4581. ΓòÉΓòÉΓòÉ 8.5.2.1. Packedset functions ΓòÉΓòÉΓòÉ
  4582.  
  4583. Values of PACKEDSET types are represented as sequences of bits The current 
  4584. implementation does not distinguish between set and packedset types.. The bit 
  4585. number 0 is the least significant bit for a given platform. The following is 
  4586. true, where v is a variable of the type CARDINAL: 
  4587.  
  4588.         CAST(CARDINAL,BITSET{0}) = VAL(CARDINAL,1)
  4589.         SHIFT(CAST(BITSET,v),1)  = v * 2
  4590.         SHIFT(CAST(BITSET,v),-1) = v DIV 2
  4591.  
  4592. The functions ROTATE and SHIFT can be applied to a set with size less than or 
  4593. equal to the size of BITSET. 
  4594.  
  4595. PROCEDURE ROTATE(x: T; n: integer): T;
  4596.  
  4597. Returns the value of x rotated n bits to the left (for positive n) or to the 
  4598. right (for negative n). 
  4599.  
  4600. PROCEDURE SHIFT(x: T; n: integer): T;
  4601.  
  4602. Returns the value of x logically shifted n bits to the left (for positive n) or 
  4603. to the right (for negative n). 
  4604.  
  4605.  
  4606. ΓòÉΓòÉΓòÉ 8.5.2.2. Non-standard functions ΓòÉΓòÉΓòÉ
  4607.  
  4608. PROCEDURE CC(n: whole constant): BOOLEAN;
  4609.  
  4610. Returns TRUE if the corresponding condition flag is set. The function is not 
  4611. implemented in the current release. 
  4612.  
  4613. PROCEDURE BIT(adr: T; bit: INTEGER): BOOLEAN;
  4614.  
  4615. Returns bit n of Mem[adr]. T is either ADDRESS or whole type. 
  4616.  
  4617.  
  4618. ΓòÉΓòÉΓòÉ 8.5.3. System procedures ΓòÉΓòÉΓòÉ
  4619.  
  4620. Note: all these procedures are non-standard. 
  4621.  
  4622. PROCEDURE MOVE (src, dst: ADDRESS; size: CARDINAL);
  4623.  
  4624. Copies size bytes from a memory location specified by src to a memory location 
  4625. specified by dst. 
  4626.  
  4627. PROCEDURE FILL(adr : ADDRESS; val : BYTE; size : CARDINAL;);
  4628.  
  4629. Fill a memory block of size size starting from a memory location specified by 
  4630. adr with the value of val using the assembly language STOS instruction. 
  4631.  
  4632. PROCEDURE GET (adr: ADDRESS; VAR v: SimpleType);
  4633. PROCEDURE PUT (adr: ADDRESS;     x: SimpleType);
  4634.  
  4635. Gets/puts a value from/to address specified by adr. The second parameter cannot 
  4636. be of a record or array type. 
  4637.  
  4638. VAR i: INTEGER;
  4639.  
  4640.   GET (128, i);   (* get system cell value *)
  4641.   i := i+20;      (* change it             *)
  4642.   PUT (128, i);   (* and put back          *)
  4643.  
  4644. PROCEDURE CODE(...);
  4645.  
  4646. The procedure is intended to embed a sequence of machine instructions directly 
  4647. into the generated code. The procedure is not implemented in the current 
  4648. release. 
  4649.  
  4650.  
  4651. ΓòÉΓòÉΓòÉ 8.6. Language extensions ΓòÉΓòÉΓòÉ
  4652.  
  4653. WARNING: Using extensions may cause problems with the software portability to 
  4654. other compilers 
  4655.  
  4656. In the standard mode the XDS Modula-2 compiler is ISO compatible (See ISO 
  4657. Standard compliance). A set of language extensions may be enabled using the 
  4658. M2EXTENSIONS and M2ADDTYPES options. 
  4659.  
  4660. The main purposes of supporting the language extensions are 
  4661.  
  4662.      to improve interfacing with other languages (See Chapter Multilanguage 
  4663.       programming) 
  4664.  
  4665.      to simplify migration from Modula-2 to Oberon-2 
  4666.  
  4667.      to implement important features not found in Modula-2 
  4668.  
  4669.      to provide backward compatibility with previous releases 
  4670.  
  4671.      Lexical extensions 
  4672.      Additional numeric types 
  4673.      Assignment compatibility with BYTE 
  4674.      Dynamic arrays 
  4675.      Constant array constructors 
  4676.      Set complement 
  4677.      Read-only parameters 
  4678.      Variable number of parameters 
  4679.      Read-only export 
  4680.      Renaming of imported modules 
  4681.      NEW and DISPOSE for dynamic arrays 
  4682.      HALT 
  4683.      ASSERT 
  4684.  
  4685.  
  4686. ΓòÉΓòÉΓòÉ 8.6.1. Lexical extensions ΓòÉΓòÉΓòÉ
  4687.  
  4688.      Comments 
  4689.      Numeric constants 
  4690.  
  4691.  
  4692. ΓòÉΓòÉΓòÉ 8.6.1.1. Comments ΓòÉΓòÉΓòÉ
  4693.  
  4694. NOTE: Only valid when option M2EXTENSIONS is set. 
  4695.  
  4696. As well as (**), there is another valid format for comments in the source 
  4697. texts. The portion of a line from ``-'' to the end is considered as a comment. 
  4698.  
  4699.      Example 
  4700.  
  4701.  Example 
  4702.  
  4703.     VAR i: INTEGER; -- this is a comment
  4704.   --(*
  4705.     i:=0; (* this line will be compiled *)
  4706.   --*)
  4707.  
  4708.  
  4709. ΓòÉΓòÉΓòÉ 8.6.1.2. Numeric constants ΓòÉΓòÉΓòÉ
  4710.  
  4711. NOTE: Only valid when option M2EXTENSIONS is set. 
  4712.  
  4713. Both Modula-2 and Oberon-2 syntax rules for the numeric and character 
  4714. representations may be used. 
  4715.  
  4716. number      =["+"|"-"]integer|real.
  4717. integer     = digit{digit}
  4718.             |octalDigit{octalDigit}"B"
  4719.             |digit{hexDigit}"X".
  4720. real        =digit{digit}"."{digit}[ScaleFactor].
  4721. ScaleFactor = ("E"|"D")["+"|"-"]digit{digit}.
  4722.  
  4723. character   ='"'char'"'|"'"char"'"
  4724.             |digit{hexDigit}"H"
  4725.             |octalDigit{octalDigit}"C".
  4726.  
  4727.      Examples 
  4728.  
  4729.  Examples 
  4730.  
  4731.   1991               1991 (decimal)
  4732.   0DH                13   (decimal)
  4733.   15B                13   (decimal)
  4734.   41X                "A"
  4735.   101C               "A"
  4736.  
  4737.  Note: the identifier D in the scalefactor refers to a LONGREAL value. 
  4738.  
  4739.  
  4740. ΓòÉΓòÉΓòÉ 8.6.2. Additional numeric types ΓòÉΓòÉΓòÉ
  4741.  
  4742. NOTE: Only valid when option M2ADDTYPES is set. 
  4743.  
  4744. The compiler option M2ADDTYPES allows us to use the following additional 
  4745. numeric types: 
  4746.  
  4747. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4748.  1.  SHORTINT   the integers between -128 and 127
  4749.  
  4750.  2.  LONGINT    the integers between -231 and 231-1
  4751.  
  4752.  3.  SHORTCARD  unsigned integers between 0 and 255
  4753.  
  4754.  4.  LONGCARD   unsigned integers between 0 and 232-1
  4755. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4756.  
  4757. The following terms for groups of types will be used: 
  4758.  
  4759.  Real types  for (REAL, LONGREAL) 
  4760. Integer types  for (SHORTINT, INTEGER, LONGINT) 
  4761. Cardinal types  for (SHORTCARD, CARDINAL, LONGCARD) 
  4762. Whole types  for integer  and cardinal types 
  4763. Numeric types  for whole  and real types 
  4764.  
  4765. All the integer types are implemented as subranges of an internal compiler 
  4766. integer types. Therefore, according to the compatibility rules (See 
  4767. Compatibility), the values of different integer types can be mixed in the 
  4768. expressions. The same holds for cardinal types. A mixture of integer and 
  4769. cardinal types in expressions is not allowed. As in Oberon-2, the numeric types 
  4770. form a hierarchy, and larger types include (i.e. can accept the values of) 
  4771. smaller types:  LONGREAL ?REAL ?whole types 
  4772.  
  4773. Type compatibility in expressions is extended according to the following rules 
  4774. (See Expression compatibility): 
  4775.  
  4776.      The type of the result of an arithmetic or relation operation is the 
  4777.       smallest type which includes the types of both operands. 
  4778.  
  4779.      Before the operation, the values of both operands are converted to the 
  4780.       result's type. 
  4781.  
  4782.  If the following variables are defined : 
  4783.  
  4784.        s: SHORTCARD;
  4785.        c: CARDINAL;
  4786.        i: INTEGER;
  4787.        l: LONGINT;
  4788.        r: REAL;
  4789.        lr: LONGREAL;
  4790.  
  4791.  then 
  4792.  
  4793.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4794.    Expression  Meaning               Result type
  4795.  
  4796.    s + c       VAL(CARDINAL,s) + c   CARDINAL
  4797.  
  4798.    l * i       l * VAL(LONGINT,i)    LONGINT
  4799.  
  4800.    r + 1       r + VAL(REAL,1)       REAL
  4801.  
  4802.    r = s       r = VAL(REAL,s)       BOOLEAN
  4803.  
  4804.    r + lr      VAL(LONGREAL,r) + lr  LONGREAL
  4805.  
  4806.    c + i       not allowed
  4807.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4808.  
  4809.  The assignment compatibility rules are also extended (See Assignment 
  4810.  compatibility), so an expression e of type Te is assignment compatible with a 
  4811.  variable v of type Tv if Te and Tv are of numeric types and Tv includes Te. 
  4812.  Cardinal types and integer types are assignment compatible. The compiler 
  4813.  generates the range checks whenever necessary. 
  4814.  Examples (see declarations above): 
  4815.  
  4816.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4817.    Statement  Comment
  4818.  
  4819.    i:=c;      INTEGER and CARDINAL are assignment compatible
  4820.  
  4821.    i:=s;      INTEGER and SHORTCARD are assignment compatible
  4822.  
  4823.    l:=i;      LONGINT and INTEGER are subranges of the same host type
  4824.  
  4825.    r:=i;      REAL? INTEGER
  4826.  
  4827.    r:=c;      REAL? CARDINAL
  4828.  
  4829.    lr:=r;     LONGREAL? REAL
  4830.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4831.  
  4832.  
  4833. ΓòÉΓòÉΓòÉ 8.6.3. Assignment compatibility with BYTE ΓòÉΓòÉΓòÉ
  4834.  
  4835. NOTE: Only valid when option M2EXTENSIONS is set. 
  4836.  
  4837. Expressions of types CHAR, BOOLEAN, SHORTINT, and SYSTEM.CARD8 can be assigned 
  4838. to the variables of type BYTE or passed as actual parameters to a formal 
  4839. parameter of type BYTE. 
  4840.  
  4841.  
  4842. ΓòÉΓòÉΓòÉ 8.6.4. Dynamic arrays ΓòÉΓòÉΓòÉ
  4843.  
  4844. NOTE: Only valid when option M2EXTENSIONS is set. 
  4845.  
  4846. XDS allows us to use the Oberon-2 style dynamic arrays according to the 
  4847. Oberon-2 rules. 
  4848.  
  4849. An open array is an array type with no lower and upper bound specified, i.e. 
  4850. ARRAY OF SomeType. Open arrays may be used only in procedure parameter lists or 
  4851. as a pointer base type. 
  4852.  
  4853. TYPE String = POINTER TO ARRAY OF CHAR;
  4854.  
  4855. Neither variables nor record fields may be of open array type. 
  4856.  
  4857. If the designator type is formally an open array, then the only operations 
  4858. allowed with it are indexing and passing it to a procedure. 
  4859.  
  4860. The extended versions of standard procedures NEW and DISPOSE can be used to 
  4861. create and delete the dynamic arrays (See NEW and DISPOSE for dynamic arrays). 
  4862. Example 
  4863.  
  4864. TYPE
  4865.   VECTOR = ARRAY OF REAL;
  4866.     (* 1-dim open array *)
  4867.   Vector = POINTER TO VECTOR;
  4868.     (* pointer to open array *)
  4869.   MATRIX = ARRAY OF VECTOR;
  4870.     (* 2-dim open array *)
  4871.   Matrix = POINTER TO MATRIX;
  4872.     (* pointer to this *)
  4873.  
  4874. VAR
  4875.    v: Vector;
  4876.    m: Matrix;
  4877.  
  4878. PROCEDURE ClearVector(VAR v: VECTOR);
  4879.   VAR i: CARDINAL;
  4880. BEGIN
  4881.   FOR i := 0 TO HIGH (v) DO v[i] := 0 END;
  4882. END ClearVector;
  4883.  
  4884. PROCEDURE ClearMatrix(VAR m: Matrix);
  4885.   VAR i: CARDINAL;
  4886. BEGIN
  4887.   FOR i := 0 TO HIGH (m) DO ClearVector(m[i]) END;
  4888. END ClearMatrix;
  4889.  
  4890. PROCEDURE Test;
  4891. BEGIN
  4892.   NEW(v, 10);
  4893.   NEW(m, 10, 20);
  4894.   ClearVector(v^);
  4895.   ClearMatrix(m^);
  4896.   v^[0] := 1;
  4897.   m^[1][1] := 2;
  4898.   m^[2,2] := 1000;
  4899.   DISPOSE(v);
  4900.   DISPOSE(m);
  4901. END Test;
  4902.  
  4903.  
  4904. ΓòÉΓòÉΓòÉ 8.6.5. Constant array constructors ΓòÉΓòÉΓòÉ
  4905.  
  4906. NOTE: Only valid when option M2EXTENSIONS is set. 
  4907.  
  4908. XDS allows the declaration of constant arrays in the form 
  4909.  
  4910.         ARRAY OF QualIdent "{" ExprList "}".
  4911.  
  4912. QualIdent should refer to a basic type, range or enumeration type, and all 
  4913. expressions within ExprList should be of this type. 
  4914.  
  4915. Note: structured types and non-constant expressions are not allowed. 
  4916.  
  4917. The actual type of such a constant is ARRAY [0..n] OF QualIdent, where n+1 is 
  4918. the number of expressions in ExprList. 
  4919. Example 
  4920.  
  4921. CONST table = ARRAY OF INTEGER {1, 2+3, 3};
  4922.  
  4923. Constant arrays are subject to the same rules as all other constants, and may 
  4924. be read as a normal array. 
  4925.  
  4926. In some cases constructors of this form are more convenient than ISO standard 
  4927. value constructors (See Value constructors), because you do not need to declare 
  4928. a type and to calculate manually the number of expressions. However, to make 
  4929. your programs more portable, we recommend to use the standard features. 
  4930.  
  4931.  
  4932. ΓòÉΓòÉΓòÉ 8.6.6. Set complement ΓòÉΓòÉΓòÉ
  4933.  
  4934. NOTE: Only valid when option M2EXTENSIONS is set. 
  4935.  
  4936. As in Oberon-2 a unary minus applied to a set denotes the complement of that 
  4937. set, i.e. -x is the set of all values which are not the elements of x. 
  4938.  
  4939. TYPE SmallSet = SET OF [0..5];
  4940. VAR x, y: SmallSet;
  4941. BEGIN
  4942.   x := SmallSet{1,3,5};
  4943.   y := -x;                  (* y = {0, 2, 4} *)
  4944.   y := SmallSet{0..5} - x;  (* y = {0, 2, 4} *)
  4945. END;
  4946.  
  4947.  
  4948. ΓòÉΓòÉΓòÉ 8.6.7. Read-only parameters ΓòÉΓòÉΓòÉ
  4949.  
  4950. NOTE: Only valid when option M2EXTENSIONS is set. 
  4951.  
  4952. In a formal parameter's section, the symbol "-" may be placed after the name of 
  4953. a value parameter. Such a parameter is called read-only; its value can not be 
  4954. changed in the procedure body. Read-only parameters need not be copied before 
  4955. procedure activation; this enables generation of procedure calls with 
  4956. structured parameters to be made more effective. 
  4957.  
  4958. For ARRAY and RECORD read-only parameters, the array elements and record fields 
  4959. are protected. Read-only parameters cannot be used in the definition modules. 
  4960.  
  4961. We recommend to use read-only parameters with care. The compiler does not check 
  4962. that the read-only parameter is not modified via the another parameter or 
  4963. global variable. 
  4964. Example 
  4965.  
  4966. PROCEDURE Foo(VAR dest: ARRAY OF CHAR;
  4967.                source-: ARRAY OF CHAR);
  4968. BEGIN
  4969.   dest[0]:='a';
  4970.   dest[1]:=source[0];
  4971. END Foo;
  4972.  
  4973. The call Foo(x,x) produces the wrong result, because the first statement 
  4974. changes the value of source[0] (source is not copied and points to the same 
  4975. location as dest). 
  4976.  
  4977.  
  4978. ΓòÉΓòÉΓòÉ 8.6.8. Variable number of parameters ΓòÉΓòÉΓòÉ
  4979.  
  4980. NOTE: Only valid when option M2EXTENSIONS is set. 
  4981.  
  4982. The last formal parameter in a procedure may be declared as a ``sequence of 
  4983. bytes'' (SEQ-parameter). In a procedure call, any (possibly empty) sequence of 
  4984. actual parameters may be substituted for such a parameter. Actual parameters 
  4985. corresponding to a sequence parameter may be of any type. 
  4986.  
  4987. Only the declaration 
  4988.  
  4989.      SEQ name: SYSTEM.BYTE
  4990.  
  4991. is allowed. Procedures may have only one SEQ parameter, and this must be the 
  4992. last element of the list of its formal parameters. 
  4993.  
  4994. Within the procedure, sequence parameters are very similar to ARRAY parameters. 
  4995. This means that : 
  4996.  
  4997.      HIGH function can be applied to the parameter; 
  4998.  
  4999.      a SEQ actual parameter may be subsequently passed to a further procedure 
  5000.  
  5001.      i-th byte of the sequence s can be accessed by s[i], like an array 
  5002.       element. 
  5003.  
  5004.  An array of bytes, which is passed to a procedure as a formal SEQ-parameter, 
  5005.  is formed as follows: 
  5006.  
  5007.      values of all actual parameters forming the sequence are represented as 
  5008.       described below and concatenated in an array in their textual order 
  5009.  
  5010.      integer values are converted to LONGINT 
  5011.  
  5012.      BOOLEAN, CHAR, cardinal and enumeration values are converted to LONGCARD 
  5013.  
  5014.      values of the range types are converted according to their base type 
  5015.  
  5016.      real values are converted to LONGREAL 
  5017.  
  5018.      values of pointer, opaque and procedure types are converted to ADDRESS 
  5019.  
  5020.      a structured value (record or array) is interpreted as an array of bytes 
  5021.       and passed as a sequence of: 
  5022.  
  5023.         -  address of a structure 
  5024.  
  5025.         -  zero word (reserved for future extensions) 
  5026.  
  5027.         -  size of a structure (in LOCs) minus one 
  5028.  
  5029.  See Sequence parameters for further information. 
  5030.  
  5031.  
  5032. ΓòÉΓòÉΓòÉ 8.6.9. Read-only export ΓòÉΓòÉΓòÉ
  5033.  
  5034. NOTE: Only valid when option M2EXTENSIONS is set. 
  5035.  
  5036. The Oberon-2 read-only export symbol "-", after a variable or field identifier 
  5037. in a definition module will define the identifier as read-only for any client. 
  5038. Only the module in which a read-only identifier is declared may change its 
  5039. value. 
  5040.  
  5041. The compiler will not allow the value of read-only exported object to be 
  5042. changed explicitly (by an assignment) or implicitly (passing as a VAR 
  5043. parameter). 
  5044.  
  5045. For read-only variables of an array or record type, both array elements and 
  5046. record fields are also read-only. 
  5047. Example (extract from definition module): 
  5048.  
  5049. TYPE Rec = RECORD
  5050.   n-: INTEGER;
  5051.   m : INTEGER;
  5052. END;
  5053.  
  5054. VAR
  5055.   in-: FILE;
  5056.   x-: Rec;
  5057.  
  5058.  
  5059. ΓòÉΓòÉΓòÉ 8.6.10. Renaming of imported modules ΓòÉΓòÉΓòÉ
  5060.  
  5061. NOTE: Only valid when option M2EXTENSIONS is set. 
  5062.  
  5063. An imported module can be renamed inside an importing module. The real name of 
  5064. the module becomes invisible. 
  5065.  
  5066. Import = IMPORT [ Ident ":=" ] Ident
  5067.           { "," [ Ident ":=" ] ident } ";".
  5068.  
  5069. Example 
  5070.  
  5071. MODULE test;
  5072. IMPORT vw := VirtualWorkstation;
  5073.  
  5074. VAR ws: vw.Station;
  5075.  
  5076. BEGIN
  5077.   ws := vw.open();
  5078. END test.
  5079.  
  5080.  
  5081. ΓòÉΓòÉΓòÉ 8.6.11. NEW and DISPOSE for dynamic arrays ΓòÉΓòÉΓòÉ
  5082.  
  5083. Standard procedures NEW and DISPOSE can be applied to the variables of a 
  5084. dynamic array type (See Dynamic arrays). If the STORAGE option is OFF. 
  5085. procedures DYNALLOCATE and DYNDEALLOCATE have to be visible in the calling 
  5086. context: 
  5087.  
  5088. PROCEDURE DYNALLOCATE(VAR a: ADDRESS;
  5089.                        size: CARDINAL;
  5090.                         len: ARRAY OF CARDINAL);
  5091.  
  5092. The procedure must allocate a dynamic array, where size is the size of array 
  5093. base type (the size of an element) and len[i] is the length of the array in 
  5094. i-th dimension. 
  5095.  
  5096. PROCEDURE DYNDEALLOCATE(VAR a: ADDRESS;
  5097.                      size,dim: CARDINAL);
  5098.  
  5099. The procedure must deallocate a dynamic array, where size is the size of an 
  5100. element and dim is the number of dimensions. 
  5101.  
  5102. Dynamic arrays are represented as a pointer to the so-called array descriptor 
  5103. (See Array types). 
  5104.  
  5105.  
  5106. ΓòÉΓòÉΓòÉ 8.6.12. HALT ΓòÉΓòÉΓòÉ
  5107.  
  5108. NOTE: Only valid when option M2EXTENSIONS is set. 
  5109.  
  5110. An optional integer parameter is allowed for the HALT procedure. 
  5111.  
  5112. PROCEDURE HALT ([code: INTEGER]);
  5113.  
  5114. HALT terminates the program execution with an optional return code. Consult 
  5115. your operating system/environment documentation for more details. 
  5116.  
  5117.  
  5118. ΓòÉΓòÉΓòÉ 8.6.13. ASSERT ΓòÉΓòÉΓòÉ
  5119.  
  5120. NOTE: Only valid when option M2EXTENSIONS is set. 
  5121.  
  5122. The procedure ASSERT checks its boolean parameter and terminates the program if 
  5123. it is not TRUE. The second optional parameter denotes task termination code. If 
  5124. it is omitted, a standard value is assumed. 
  5125.  
  5126. PROCEDURE ASSERT(cond: BOOLEAN [; code: INTEGER]);
  5127.  
  5128. The call ASSERT(expr,code) is equal to 
  5129.  
  5130. IF NOT expr THEN HALT(code) END;
  5131.  
  5132.  
  5133. ΓòÉΓòÉΓòÉ 8.7. Source code directives ΓòÉΓòÉΓòÉ
  5134.  
  5135. Source code directives (or pragmas) are used for setting of compilation options 
  5136. in the source text and for selection of the specific source text to be compiled 
  5137. (conditional compilation). The ISO Modula-2 standard does not describe the 
  5138. syntax of pragmas. XDS allows one to use source code directives in both 
  5139. Modula-2 and Oberon-2. The syntax described in The Oakwood Guidelines for the 
  5140. Oberon-2 Compiler Developers is used. 
  5141.  
  5142.      Inline options and equations 
  5143.      Conditional compilation 
  5144.  
  5145.  
  5146. ΓòÉΓòÉΓòÉ 8.7.1. Inline options and equations ΓòÉΓòÉΓòÉ
  5147.  
  5148. In some cases it is more preferable to set the compiler options within the 
  5149. source text. Some compiler options such as MAIN are more meaningful in the 
  5150. source file before the module header, and some, such as run-time checks, 
  5151. between statements. 
  5152.  
  5153. XDS allows options to be changed in source text by using standard ISO pseudo 
  5154. comments <* ... *>The old style of pragmas (*\$..*) is supported to provide 
  5155. backward compatibility, but the compiler reports ``obsolete syntax'' warning. 
  5156. Some options can only be placed in source text before the module header (i.e. 
  5157. before keywords IMPLEMENTATION, DEFINITION or MODULE). These options will be 
  5158. ignored if found elsewhere in the source text. See Description of options for 
  5159. more details. 
  5160.  
  5161. The format of an inline option or equation setting is described by the 
  5162. following syntax: 
  5163.  
  5164. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5165.  PragmaBody   <* Switch *>
  5166.  
  5167.  Switch       NewStyle | OldStyle | Equation | PragmaStyle
  5168.  
  5169.  NewStyle     [ NEW ] name [ '+' | '-' | '=' string ]
  5170.  
  5171.  OldStyle     ('+' | '-') name
  5172.  
  5173.  PragmaStyle  '$'  Modifier
  5174.  
  5175.  Modifier     name '+' | name '-' | > | < | !
  5176. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5177.  
  5178. The NewStyle and PragmaStyle PragmaStyle is an extension of Oakwood standard - 
  5179. option names are used instead of pragma letters.  are proposed as the Oakwood 
  5180. standard for Oberon-2, OldStyle is the style used in the previous XDS release. 
  5181. All option names are case-independent. In the OldStyle and PragmaStyle there 
  5182. should be no space between <* and +, - or $. OldStyle does not allow to declare 
  5183. or change an equation. 
  5184.  
  5185. In all cases the symbol + sets the corresponding option ON, and the symbol - 
  5186. sets it OFF. In the pragmaStyle special modifiers have the following meaning: 
  5187.  
  5188.  <         saves the current option's state 
  5189.  
  5190.  >         restores the last saved option's state 
  5191.  
  5192.  !         restore option's state set prior to the compilation of the given 
  5193.            module 
  5194.  
  5195.  Examples 
  5196.  
  5197.   PROCEDURE Length(VAR a: ARRAY OF CHAR): CARDINAL;
  5198.     VAR i: CARDINAL;
  5199.   BEGIN
  5200.     <*$<*>              (* save state *)
  5201.     <* CHECKINDEX - *>  (* turn CHECKINDEX off *)
  5202.     i := 0;
  5203.     WHILE (i<=HIGH(a)) & (a[i]#0C) DO INC(i) END;
  5204.     <*$>*>   (* restore option's state *)
  5205.     RETURN i;
  5206.   END Length;
  5207.  
  5208.   <* ALIGNMENT = "2" *>
  5209.   TYPE
  5210.     R = RECORD      (* This record is 6 bytes long *)
  5211.           f1: CHAR;
  5212.           f2: CARDINAL;
  5213.         END;
  5214.  
  5215.  
  5216. ΓòÉΓòÉΓòÉ 8.7.2. Conditional compilation ΓòÉΓòÉΓòÉ
  5217.  
  5218. It is possible to use the conditional compilation with Modula-2 and 
  5219. Oberon-2only if the O2ISOPRAGMA option is set ON compilers via the standard ISO 
  5220. pragma notation <* *>. Conditional compilation statements can be placed 
  5221. anywhere in the source code. The syntax of the conditional compilation IF 
  5222. statement: 
  5223.  
  5224.   IfStatement      = <* IF Expression THEN *>  text
  5225.                    { <* ELSIF Expression THEN *> text }
  5226.                    [ <* ELSE *> text ]
  5227.                      <* END *>
  5228.   Expression       = SimpleExpression
  5229.                      [ ("=" | "#") SimpleExpression].
  5230.   SimpleExpression = Term { "OR" Term}.
  5231.   Term             = Factor { "&" Factor}.
  5232.   Factor           = ident | string |
  5233.                      "DEFINED" "(" ident ")" |
  5234.                      "(" Expression ")" |
  5235.                      "~" Factor | "NOT" Factor.
  5236.   ident            = option | equation.
  5237.  
  5238. An operand in an expressions is either a name of option or equation or a string 
  5239. literal. An option has the value TRUE, if it was set to TRUE in the 
  5240. configuration or project file, on the command line, or within the source text. 
  5241. An option has the value FALSE, if it was set to FALSE explicitly or was not 
  5242. defined at all. The compiler will report a warning if an undeclared option or 
  5243. equation is used as a conditional compilation identifier. 
  5244. Examples 
  5245.  
  5246.   IMPORT lib :=
  5247.         <* IF  __GEN_X86__ THEN *> MyX86Lib;
  5248.         <* ELSIF __GEN_C__ THEN *> MyCLib;
  5249.         <* ELSE *> *** Unknown ***
  5250.         <* END *>
  5251.  
  5252.   CONST Win = <* IF Windows THEN *> TRUE
  5253.               <* ELSE *> FALSE
  5254.               <* END *>;
  5255.  
  5256.   <* IF DEFINED(Debug) & (DebugLevel = "2") THEN *>
  5257.      PrintDebugInformation;
  5258.   <* END *>;
  5259.  
  5260.   <* IF platform = "OS2" THEN *>
  5261.     Strings.Capitalize(filename);
  5262.     <* IF NOT HPFS THEN *>
  5263.       TruncateFileName(filename);
  5264.     <* END *>
  5265.   <* END *>
  5266.  
  5267.  
  5268. ΓòÉΓòÉΓòÉ 9. XDS Oberon-2 ΓòÉΓòÉΓòÉ
  5269.  
  5270. This chapter includes the details of the Oberon-2 language which are specific 
  5271. for this implementation. In the standard mode When the options O2EXTENSIONS and 
  5272. O2NUMEXT are OFF. XDS Oberon-2 is fully compatible with ETH compilers (See 
  5273. Oberon-2 report for the language report). The last changes to the language are 
  5274. described in Last changes to the language. 
  5275.  
  5276. To provide a smooth path from Modula-2 to Oberon-2 XDS allows all Modula-2 data 
  5277. types to be used in Oberon-2 modules (See Using Modula-2 features). 
  5278.  
  5279. Several language extensions are implemented in the language according to The 
  5280. Oakwood Guidelines for the Oberon-2 Compiler Developers These guidelines have 
  5281. been produced by a group of Oberon-2 compiler developers, including ETH 
  5282. developers, after a meeting at the Oakwood Hotel in Croydon, UK in June 1993. 
  5283. (See Oakwood numeric extensions). Other language extensions are described in 
  5284. Language extensions. As XDS is a truly multi-lingual system, special features 
  5285. were introduced to provide for foreign language interfaces (See Chapter 
  5286. Multilanguage programming). 
  5287.  
  5288.      The Oberon environment 
  5289.      Last changes to the language 
  5290.      Oakwood numeric extensions 
  5291.      Using Modula-2 features 
  5292.      Language extensions 
  5293.      The module SYSTEM 
  5294.  
  5295.  
  5296. ΓòÉΓòÉΓòÉ 9.1. The Oberon environment ΓòÉΓòÉΓòÉ
  5297.  
  5298. The Oberon-2 language was originally designed for use in an environment that 
  5299. provides the command activation, garbage collection, and dynamic loading of the 
  5300. modules. Although not being a part of the language, these features contribute 
  5301. to the power of Oberon-2. 
  5302.  
  5303. The garbage collector and command activation are implemented in the Oberon 
  5304. Run-Time Support and can be used in any program. The dynamic loader is not 
  5305. provided in the current release. See The oberonRTS module for further 
  5306. information. 
  5307.  
  5308.      Program structure 
  5309.      Creating a definition 
  5310.  
  5311.  
  5312. ΓòÉΓòÉΓòÉ 9.1.1. Program structure ΓòÉΓòÉΓòÉ
  5313.  
  5314. In the Oberon-2 environment, any declared parameterless procedure can be 
  5315. considered as a main procedure and can be called by its name (a qualified 
  5316. identifier of the form ModuleName.ProcName). 
  5317.  
  5318. Due to the nature of XDS, and its freedom from the Oberon system, a different 
  5319. approach is to be taken to declare the `top level' or program modules. 
  5320.  
  5321. The module which contains the top level of your program must be declared as 
  5322. such by translating it with the MAIN option set. This will generate an entry 
  5323. point to your program. Only one module per program shall be compiled with the 
  5324. option set. 
  5325.  
  5326.  
  5327. ΓòÉΓòÉΓòÉ 9.1.2. Creating a definition ΓòÉΓòÉΓòÉ
  5328.  
  5329. XDS provides two different ways to create a definition for Oberon-2 module: 
  5330.  
  5331.      the BROWSE operation mode creates a definition module from a symbol file 
  5332.       (See BROWSE mode); 
  5333.  
  5334.      the MAKEDEF option forces the Oberon compiler to generate a (pseudo) 
  5335.       definition module after a successful compilation of an Oberon module. 
  5336.  
  5337.  The MAKEDEF option provides additional services: the compiler will preserve 
  5338.  the so-called exported comments (i.e. comments which start with `(**') if the 
  5339.  XCOMMENTS option is set. 
  5340.  
  5341.  The generated pseudo-definition module contains all exported declarations in 
  5342.  the order of appearance in the source text. All exported comments are placed 
  5343.  in the appropriate positions. 
  5344.  
  5345.  The definition module can be generated in three styles.The BSTYLE equation can 
  5346.  be used to choose one of the styles: DEF (default), DOC or MOD. 
  5347.  
  5348.  The DEF style 
  5349.  
  5350.            This produces an ETH-style definition module. All type-bound 
  5351.            procedures (methods) and relative comments are shown as a part of 
  5352.            the corresponding record type. 
  5353.  
  5354.            This is the only style for which the BSREDEFINE and BSCLOSURE 
  5355.            options are applicable. 
  5356.  
  5357.  The DOC style 
  5358.  
  5359.            This produces a pseudo-definition module in which methods are shown 
  5360.            as a part of an appropriate record type (ignoring comments) and in 
  5361.            the same positions as they occur in the source text. 
  5362.  
  5363.  The MOD style 
  5364.  
  5365.            This attempts to produce a file which can be compiled as an Oberon 
  5366.            module after a slight modification (i.e.the file will contain "END 
  5367.            procname" etc.) 
  5368.  
  5369.  
  5370. ΓòÉΓòÉΓòÉ 9.2. Last changes to the language ΓòÉΓòÉΓòÉ
  5371.  
  5372.      ASSERT 
  5373.      Underscores in identifiers 
  5374.      Source code directives 
  5375.  
  5376.  
  5377. ΓòÉΓòÉΓòÉ 9.2.1. ASSERT ΓòÉΓòÉΓòÉ
  5378.  
  5379. The procedure ASSERT checks its boolean parameter and terminates the program if 
  5380. it is not TRUE. The second optional parameter denotes task termination code. If 
  5381. omitted, a standard value is assumed. 
  5382.  
  5383. PROCEDURE ASSERT(cond: BOOLEAN [; code: INTEGER]);
  5384.  
  5385. The call ASSERT(expr,code) is equal to 
  5386.  
  5387. IF NOT expr THEN HALT(code) END;
  5388.  
  5389.  
  5390. ΓòÉΓòÉΓòÉ 9.2.2. Underscores in identifiers ΓòÉΓòÉΓòÉ
  5391.  
  5392. According to the Oakwood Guidelines an underscore "_" may be used in 
  5393. identifiers (as a letter). 
  5394.  
  5395. ident = ( letter | "_" ) { letter | digit | "_" }.
  5396.  
  5397. We recommend to use underscores with care, as it may cause problems with the 
  5398. software portability to other compilers. This feature may be important when 
  5399. interfacing with foreign languages (See Chapter Multilanguage programming). 
  5400.  
  5401.  
  5402. ΓòÉΓòÉΓòÉ 9.2.3. Source code directives ΓòÉΓòÉΓòÉ
  5403.  
  5404. Source code directives (or pragmas) are used for setting of compilation options 
  5405. in the source text and for selection of the specific source text to be compiled 
  5406. (conditional compilation). According to the Oakwood Guidelines all directives 
  5407. are contained in ISO Modula-2 style pseudo comments using angled brackets <* 
  5408. ... *>. 
  5409.  
  5410. The additional language constructs should not be considered to be part of the 
  5411. Oberon-2 language. Rather they defined a separate compiler control language 
  5412. that coexist with Oberon-2. The option O2ISOPRAGMA allows one to use pragmas. 
  5413.  
  5414. The syntax of the directives is the same for Modula-2 and Oberon-2. See Source 
  5415. code directives for further details. 
  5416.  
  5417.  
  5418. ΓòÉΓòÉΓòÉ 9.3. Oakwood numeric extensions ΓòÉΓòÉΓòÉ
  5419.  
  5420. XDS Oberon-2 supports two extensions which are of importance for scientific 
  5421. programming, namely 
  5422.  
  5423.      complex numbers 
  5424.  
  5425.      in-line exponentiation operator 
  5426.  
  5427.  The O2NUMEXT option should be set to use these extensions. 
  5428.  
  5429.      Complex numbers 
  5430.      In-line exponentiation 
  5431.  
  5432.  
  5433. ΓòÉΓòÉΓòÉ 9.3.1. Complex numbers ΓòÉΓòÉΓòÉ
  5434.  
  5435. NOTE: Only valid when option O2NUMEXT is set. 
  5436.  
  5437. Two additional types are included in the type hierarchy if the O2NUMEXT option 
  5438. is set: 
  5439.  
  5440. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5441.  COMPLEX      defined as  (REAL,REAL)
  5442.  
  5443.  LONGCOMPLEX  defined as  (LONGREAL,LONGREAL)
  5444. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5445.  
  5446. All numeric types form a (partial) hierarchy  LONGCOMPLEX ? 
  5447.  
  5448. l COMPLEX 
  5449. LONGREAL 
  5450.  
  5451. REAL ?whole types  A common mathematical notation is used for complex number 
  5452. literals: 
  5453.  
  5454. number = integer | real | complex.
  5455. complex = real "i".
  5456.  
  5457. A literal of the form 5.0i denotes a complex number with real part equal to 
  5458. zero and an imaginary part equal to 5.0. Complex constants with a non-zero real 
  5459. part can be described using arithmetic operators. 
  5460.  
  5461. CONST
  5462.   i = 1.i;
  5463.   x = 1. + 1.i;
  5464.  
  5465. For the declarations 
  5466.  
  5467. VAR
  5468.   c: COMPLEX;
  5469.   l: LONGCOMPLEX;
  5470.   r: REAL;
  5471.   x: INTEGER;
  5472.  
  5473. the following statements are valid: 
  5474.  
  5475.   c:=i+r;
  5476.   l:=c;
  5477.   l:=c*r;
  5478.   l:=l*c;
  5479.  
  5480. New conversion functions RE and IM can be used to obtain a real or imaginary 
  5481. part of a value of a complex type. Both functions have one parameter. If the 
  5482. parameter is of the COMPLEX type, both functions return the REAL value; if the 
  5483. parameter is of the LONGCOMPLEX type, functions return the LONGREAL value; 
  5484. otherwise the parameter should be a complex constant and functions return real 
  5485. constant. 
  5486.  
  5487. A complex value can be formed by applying the standard function CMPLX to two 
  5488. reals. If both CMPLX arguments are real constants, the result is a complex 
  5489. constant. 
  5490.  
  5491. CONST i = CMPLX(0.0,1.0);
  5492.  
  5493. If both expressions are of the REAL type, the function returns the COMPLEX 
  5494. value, otherwise it returns the LONGCOMPLEX value. 
  5495.  
  5496.  
  5497. ΓòÉΓòÉΓòÉ 9.3.2. In-line exponentiation ΓòÉΓòÉΓòÉ
  5498.  
  5499. NOTE: Only valid when option O2NUMEXT is set. 
  5500.  
  5501. The exponentiation operator ** provides a convenient notation for arithmetic 
  5502. expressions, rather than using function calls. It is an arithmetic operator 
  5503. which has a higher precedence than multiplication operators. 
  5504.  
  5505. Term     =  Exponent { MulOp Exponent }.
  5506. Exponent =  Factor { "**" Factor }.
  5507.  
  5508. Note: the operator is right-associated:  a**b**c  is evaluated as  abc 
  5509.  
  5510. The left operand of the exponentiation (a**b) should be any numeric value 
  5511. (including complex), while the right operand should be of a real or integer 
  5512. type. The result type does not depend of the type of right operand and is 
  5513. defined by the table: 
  5514.  
  5515. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5516.  Type of left operand  Result type
  5517.  
  5518.  integer type          REAL
  5519.  
  5520.  REAL                  REAL
  5521.  
  5522.  LONGREAL              LONGREAL
  5523.  
  5524.  COMPLEX               COMPLEX
  5525.  
  5526.  LONGCOMPLEX           LONGCOMPLEX
  5527. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5528.  
  5529.  
  5530. ΓòÉΓòÉΓòÉ 9.4. Using Modula-2 features ΓòÉΓòÉΓòÉ
  5531.  
  5532. All Modula-2 types and corresponding operations can be used in Oberon-2, 
  5533. including enumeration types, range types, records with variant parts, sets, 
  5534. etc. 
  5535. Important Notes: 
  5536.  
  5537.      It is not allowed to declare the Modula-2 types in an Oberon-2 module. 
  5538.  
  5539.      A module using Modula-2 features may be non-portable to other compilers. 
  5540.  
  5541.  Example 
  5542.  
  5543.   (*MODULA-2*) DEFINITION MODULE UsefulTypes;
  5544.  
  5545.   TYPE
  5546.     TranslationTable = ARRAY CHAR OF CHAR;
  5547.     Color  = (red,green,blue);
  5548.     Colors = SET OF Color;
  5549.  
  5550.   END UsefulTypes.
  5551.  
  5552.   (*OBERON-2*) MODULE UsingM2;
  5553.  
  5554.   IMPORT UsefulTypes;
  5555.  
  5556.   TYPE
  5557.     TranslationTable* = UsefulTypes.TranslationTable;
  5558.  
  5559.   VAR colors*: UsefulTypes.Color;
  5560.  
  5561.   BEGIN
  5562.     colors:=UsefulTypes.Colors{UsefulTypes.red};
  5563.   END UsingM2.
  5564.  
  5565.  
  5566. ΓòÉΓòÉΓòÉ 9.5. Language extensions ΓòÉΓòÉΓòÉ
  5567.  
  5568. WARNING: Using extensions may cause problems with the software portability to 
  5569. other compilers. 
  5570.  
  5571. In the standard mode the XDS Oberon-2 compiler is fully compatible with ETH 
  5572. compilers (See also Last changes to the language). The O2EXTENSIONS option 
  5573. enables some language extensions. The main purposes of language extensions are 
  5574.  
  5575.      to improve interfacing with other languages (See Chapter Multilanguage 
  5576.       programming). 
  5577.  
  5578.      to provide backward compatibility with the previous versions of XDS. 
  5579.  
  5580.   See also 
  5581.  
  5582.      Source language directives (Source code directives) 
  5583.  
  5584.      Oakwood numeric extensions (Oakwood numeric extensions). 
  5585.  
  5586.      Comments 
  5587.      String concatenation 
  5588.      VAL function 
  5589.      Read-only parameters 
  5590.      Variable number of parameters 
  5591.      Value constructors 
  5592.  
  5593.  
  5594. ΓòÉΓòÉΓòÉ 9.5.1. Comments ΓòÉΓòÉΓòÉ
  5595.  
  5596. NOTE: Only valid when option O2EXTENSIONS is set. 
  5597.  
  5598. As well as "(**)", there is another valid format for comments in source texts. 
  5599. The portion of a line from "-" to the end is considered as a comment. 
  5600. Example 
  5601.  
  5602. VAR j: INTEGER; -- this is a comment
  5603.  
  5604.  
  5605. ΓòÉΓòÉΓòÉ 9.5.2. String concatenation ΓòÉΓòÉΓòÉ
  5606.  
  5607. NOTE: Only valid when option O2EXTENSIONS is set. 
  5608.  
  5609. The symbol "+" can be used for constant string and characters concatenation. 
  5610. See Strings for more details. 
  5611.  
  5612.  
  5613. ΓòÉΓòÉΓòÉ 9.5.3. VAL function ΓòÉΓòÉΓòÉ
  5614.  
  5615. NOTE: Only valid when option O2EXTENSIONS is set. 
  5616.  
  5617. The function VAL can be used to obtain a value of a specified scalar type from 
  5618. an expression of a scalar type. See Type conversions for more details. 
  5619.  
  5620. PROCEDURE VAL(Type; expr: ScalarType): Type;
  5621.  
  5622. The function can be applied to any scalar types, including the system fixed 
  5623. size types (See Whole system types). 
  5624.  
  5625.  
  5626. ΓòÉΓòÉΓòÉ 9.5.4. Read-only parameters ΓòÉΓòÉΓòÉ
  5627.  
  5628. NOTE: Only valid when option O2EXTENSIONS is set. 
  5629.  
  5630. In a formal parameter's section, the symbol "-" may stand after the name of a 
  5631. value parameter. Such a parameter is called read-only; its value can not be 
  5632. changed in the procedure's body. Read-only parameters need not be copied before 
  5633. the procedure activation; this enables the generation of procedure calls with 
  5634. structured parameters to be made more effective. Read-only parameters can not 
  5635. be used in a procedure type declaration. 
  5636.  
  5637. We recommend to use read-only parameters with care. The compiler does not check 
  5638. that the read-only parameter is not modified via the another parameter or 
  5639. global variable. 
  5640. Example 
  5641.  
  5642. PROCEDURE Foo(VAR dest: ARRAY OF CHAR;
  5643.                source-: ARRAY OF CHAR);
  5644. BEGIN
  5645.   dest[0]:='a';
  5646.   dest[1]:=source[0];
  5647. END Foo;
  5648.  
  5649. The call Foo(x,x) produces the wrong result, because the first statement 
  5650. changes the value of source[0] (source is not copied and points to the same 
  5651. location as dest). 
  5652.  
  5653.  
  5654. ΓòÉΓòÉΓòÉ 9.5.5. Variable number of parameters ΓòÉΓòÉΓòÉ
  5655.  
  5656. NOTE: Only valid when option O2EXTENSIONS is set. 
  5657.  
  5658. Everything contained in section Variable number of parameters is applicable to 
  5659. Oberon-2. 
  5660.  
  5661.  
  5662. ΓòÉΓòÉΓòÉ 9.5.6. Value constructors ΓòÉΓòÉΓòÉ
  5663.  
  5664. NOTE: Only valid when option O2EXTENSIONS is set. 
  5665.  
  5666. Everything contained in section Value constructors is applicable to Oberon-2. 
  5667.  
  5668.  
  5669. ΓòÉΓòÉΓòÉ 9.6. The module SYSTEM ΓòÉΓòÉΓòÉ
  5670.  
  5671. Low level facilities are provided by the module SYSTEM. This module does not 
  5672. exist in the same sense as other libraries but is hard-coded into the compiler 
  5673. itself. However, to use the facilities provided, identifiers must be imported 
  5674. in the usual way. 
  5675.  
  5676. Some procedures in the module SYSTEM are generic procedures that cannot be 
  5677. explicitly declared, i.e. they apply to classes of operand types. 
  5678.  
  5679. XDS Oberon-2 compiler implements all system features described in Oberon-2 
  5680. report (except GETREG, PUTREG and CC) and allows one to access to all features, 
  5681. described in the International Standard of Modula-2 (See The module SYSTEM). In 
  5682. this section we describe only features specific for this implementation. 
  5683.  
  5684.      Compatibility with BYTE 
  5685.      Whole system types 
  5686.      NEW and DISPOSE 
  5687.      M2ADR 
  5688.  
  5689.  
  5690. ΓòÉΓòÉΓòÉ 9.6.1. Compatibility with BYTE ΓòÉΓòÉΓòÉ
  5691.  
  5692. Expressions of types CHAR, BOOLEAN, SHORTINT and SYSTEM.CARD8 can be assigned 
  5693. to the variables of type BYTE or passed as actual parameters to formal 
  5694. parameters of type BYTE. 
  5695.  
  5696. If a formal variable parameter is of type ARRAY OF BYTE then the corresponding 
  5697. actual parameter may be of any type, except numeric literals. 
  5698.  
  5699.  
  5700. ΓòÉΓòÉΓòÉ 9.6.2. Whole system types ΓòÉΓòÉΓòÉ
  5701.  
  5702. Module SYSTEM contains the signed types INT8, INT16, INT32 and unsigned types 
  5703. CARD8, CARD16, CARD32, which are guaranteed to contain exactly 8, 16, or 32 
  5704. bits respectively. These types were introduced to simplify consstructing the 
  5705. interfaces to foreign libraries (See Chapter Multilanguage programming). The 
  5706. basic types SHORTINT, INTEGER, LONGINT are synonyms of INT8, INT16 and INT32 
  5707. respectively. 
  5708.  
  5709. The unsigned types form a hierarchy whereby larger types include (the values 
  5710. of) smaller types.  SYSTEM.CARD32 ?SYSTEM.CARD16 ?SYSTEM.CARD8  The whole 
  5711. hierarchy of numeric types (See also Complex numbers):  LONGREAL ?REAL ?{ 
  5712.  
  5713. l signed types 
  5714. unsigned types 
  5715.  
  5716.  
  5717.  
  5718. ΓòÉΓòÉΓòÉ 9.6.3. NEW and DISPOSE ΓòÉΓòÉΓòÉ
  5719.  
  5720. The procedure SYSTEM.NEW can be used to allocate the system memory, i.e. memory 
  5721. which is not the subject of garbage collection. SYSTEM.NEW is a generic 
  5722. procedure, which is applied to pointer types and can be used in several ways, 
  5723. depending on pointer's base type. 
  5724.  
  5725. PROCEDURE NEW(VAR p: AnyPointer [; x0,..xn: integer]);
  5726.  
  5727. Let P be defined as POINTER TO T and p is of type T. 
  5728.  
  5729. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5730.  NEW(p)            T is a record or fixed length array type. The procedure allocates a storage block of SIZE(p^) bytes and assigns its address to p.
  5731.  
  5732.  NEW(p,n)          T is a record or fixed length array type. The procedure allocates a storage block of n bytes and assigns its address to p.
  5733.  
  5734.  NEW(p,x0,..xn-1)  T is n-dimensional open array. The procedure allocates an open array of lengths given by the expressions x0,..xn-1
  5735. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5736.  
  5737. Procedure SYSTEM.DISPOSE can be used to free the block allocated by the call of 
  5738. SYSTEM.NEW. It does not immediately deallocate the block, but marks it as a 
  5739. free block. Such a block will be deallocated by the next call of the garbage 
  5740. collector. 
  5741.  
  5742. PROCEDURE DISPOSE(VAR p: AnyPointer; [size: integer]);
  5743.  
  5744. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5745.  DISPOSE(p)    T is a record or array type. The procedure deallocates storage block for pointer p.
  5746.  
  5747.  DISPOSE(p,n)  T is record or fixed length array type. The procedure deallocates storage block of n bytes.
  5748. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5749.  
  5750.  
  5751. ΓòÉΓòÉΓòÉ 9.6.4. M2ADR ΓòÉΓòÉΓòÉ
  5752.  
  5753. The SYSTEM.ADR() procdure returns LONGINT in Oberon, which is not always very 
  5754. convenient. The SYSTEM.M2ADR procedure behaves as Modula-2 SYSTEM.ADR, 
  5755. returning SYSTEM.ADDRESS: 
  5756.  
  5757. PROCEDURE M2ADR(VAR x: any type): ADDRESS; 
  5758.  
  5759.  
  5760. ΓòÉΓòÉΓòÉ 10. Multilanguage programming ΓòÉΓòÉΓòÉ
  5761.  
  5762. XDS allows the programmer to mix Modula-2, Oberon-2, C and Assembler modules, 
  5763. libraries, and object files in one project. 
  5764.  
  5765.      Modula-2 and Oberon-2 
  5766.      Direct language specification 
  5767.      Relaxation of compatibility rules 
  5768.      Interfacing to C 
  5769.  
  5770.  
  5771. ΓòÉΓòÉΓòÉ 10.1. Modula-2 and Oberon-2 ΓòÉΓòÉΓòÉ
  5772.  
  5773. It is not necessary to notify the compiler of using Modula-2 objects in 
  5774. Oberon-2 module and vice versa. The compiler will detect the language 
  5775. automatically when processing symbol files on IMPORT clause. 
  5776.  
  5777.      Basic types 
  5778.      Data structures 
  5779.      Garbage collection 
  5780.  
  5781.  
  5782. ΓòÉΓòÉΓòÉ 10.1.1. Basic types ΓòÉΓòÉΓòÉ
  5783.  
  5784. In Oberon-2 the basic types have the same length on all platforms. In Modula-2 
  5785. the size of types INTEGER, CARDINAL and BITSET may be different and depends on 
  5786. the value of the M2BASE16 option. The following table summarizes the 
  5787. correspondence between the basic types. 
  5788.  
  5789. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5790.  Type      Size  Oberon-2  2c|Modula-2
  5791.  
  5792.                            M2BASE16+    M2BASE16-
  5793.  
  5794.  integer   8     SHORTINT  -            -
  5795.  
  5796.  integer   16    INTEGER   INTEGER      -
  5797.  
  5798.  integer   32    LONGINT   -            INTEGER
  5799.  
  5800.  cardinal  8     -         -            -
  5801.  
  5802.  cardinal  16    -         CARDINAL     -
  5803.  
  5804.  cardinal  32    -         -            CARDINAL
  5805.  
  5806.  bitset    16    -         BITSET       -
  5807.  
  5808.  bitset    32    SET       -            BITSET
  5809. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5810.  
  5811. The system types INT and CARD correspond to Modula-2 INTEGER and CARDINAL types 
  5812. respectively. We recommend to use INT and CARD in Oberon-2 when importing 
  5813. Modula-2 modules. For example, if the procedure Foo is defined in the Modula-2 
  5814. definition module as 
  5815.  
  5816. DEFINITION MODULE M;
  5817.  
  5818. PROCEDURE Foo(VAR x: INTEGER);
  5819.  
  5820. END M.
  5821.  
  5822. the portable usage of this procedure in Oberon-2 is as follows: 
  5823.  
  5824.  VAR x: SYSTEM.INT;
  5825.   ...
  5826.   M.Foo(x);
  5827.  
  5828.  
  5829. ΓòÉΓòÉΓòÉ 10.1.2. Data structures ΓòÉΓòÉΓòÉ
  5830.  
  5831. XDS allows any Modula-2 data structures to be used in Oberon-2 modules, even 
  5832. those that can not be defined in Oberon-2 (that is variant records, range 
  5833. types, set types, enumerations, etc). 
  5834.  
  5835. However, the use of Modula-2 types in Oberon-2 and vice versa is restricted. 
  5836. Whenever possible XDS tries to produce the correct code. If a correct 
  5837. translation is impossible, an error is reported: 
  5838.  
  5839.      a Modula-2 record field type cannot be of an Oberon-2 pointer, record or 
  5840.       array type; 
  5841.  
  5842.      Modula-2 pointer to Oberon-2 record cannot be used in specific Oberon-2 
  5843.       constructs (type-bound procedures, type guards, etc); 
  5844.  
  5845.      an opaque type can not be defined as an Oberon pointer. 
  5846.  
  5847.  Standard procedures NEW and DISPOSE are always applied according to the 
  5848.  language of a parameter's type. For example, for the following declarations in 
  5849.  the Oberon-2 module: 
  5850.  
  5851.   TYPE
  5852.     Rec = RECORD END;
  5853.     MP  = POINTER ["Modula"] TO Rec; (* Modula pointer *)
  5854.     OP  = POINTER TO Rec;     (* Oberon pointer *)
  5855.   VAR
  5856.     m: MP;
  5857.     o: OP;
  5858.  
  5859.  The call of NEW(m) will be treated as a call of the Modula-2 default ALLOCATE, 
  5860.  while NEW(o) will be treated as a call of the standard Oberon run-time 
  5861.  routine. See also Direct language specification. 
  5862.  
  5863.  An implicit memory deallocation (garbage collection) is applied to Oberon-2 
  5864.  objects only. If a variable of the Modula-2 pointer type is declared in the 
  5865.  Oberon-2 module, it shall be deallocated explicitly. 
  5866.  Example: Using the Modula data type in Oberon 
  5867.  
  5868.   (* Modula-2*) DEFINITION MODULE m2;
  5869.   TYPE
  5870.     Rec = RECORD  (* a record with variant parts *)
  5871.       CASE tag: BOOLEAN OF
  5872.         |TRUE:  i: INTEGER;
  5873.         |FALSE: r: REAL;
  5874.       END;
  5875.     END;
  5876.     Ptr = POINTER TO Rec;
  5877.  
  5878.   VAR
  5879.     r: Rec;
  5880.     p: Ptr;
  5881.  
  5882.   PROCEDURE Foo(VAR r: Rec);
  5883.  
  5884.   END m2.
  5885.  
  5886.   (* Oberon-2 *) MODULE o2;
  5887.  
  5888.   IMPORT m2; (* import of a Modula-2 module *)
  5889.  
  5890.   VAR
  5891.     r: m2.Rec;  (* using the Modula-2 record type *)
  5892.     p: m2.Ptr;  (* using the Modula-2 pointer type *)
  5893.     x: POINTER TO m2.Rec;
  5894.  
  5895.   BEGIN
  5896.     NEW(p);     (* Modula-2 default ALLOCATE *)
  5897.     NEW(x);     (* Oberon-2 NEW *)
  5898.     m2.Foo(r);
  5899.     m2.Foo(p^);
  5900.     m2.Foo(x^);
  5901.   END o2.
  5902.  
  5903.  
  5904. ΓòÉΓòÉΓòÉ 10.1.3. Garbage collection ΓòÉΓòÉΓòÉ
  5905.  
  5906. It is important to remember that Modula-2 and Oberon-2 have different 
  5907. approaches to memory utilization. When a program contains both Modula-2 and 
  5908. Oberon-2 modules, garbage collection is used. See also Memory management. 
  5909.  
  5910.  
  5911. ΓòÉΓòÉΓòÉ 10.2. Direct language specification ΓòÉΓòÉΓòÉ
  5912.  
  5913. The compiler must know the language of implementation of any module to take 
  5914. into account different semantics of different languages and to generate a 
  5915. correct code. 
  5916.  
  5917. In some cases it is necessary for a procedure or data type to be implemented 
  5918. according to the rules of a language other than that of the whole module. XDS 
  5919. allows the language of a type or object to be specified explicitly. The direct 
  5920. language specification is allowed either if language extensions are allowed or 
  5921. if the module SYSTEM is imported. 
  5922.  
  5923. In a record, pointer, procedure type or procedure declaration, immediately 
  5924. following the keywords RECORD, POINTER or PROCEDURE, one may indicate the 
  5925. desired language (or the way in which this declaration is treated by the 
  5926. compiler) by [n], where n is a string or an integer constant expressionWe 
  5927. recommed to use strings, integer values are preserved for the backward 
  5928. compatibility.: 
  5929.  
  5930. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5931.  Convention  String     Value
  5932.  
  5933.  Oberon-2    "Oberon"   0
  5934.  
  5935.  Modula-2    "Modula"   1
  5936.  
  5937.  C           "C"        2
  5938.  
  5939.  Pascal      "Pascal"   5
  5940.  
  5941.  Win32       "StdCall"  7
  5942.  
  5943.  OS/2 API    "SysCall"  ???
  5944. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5945.  
  5946. Example 
  5947.  
  5948. TYPE
  5949.   UntracedPtr = POINTER ["Modula"] TO Rec;
  5950.  
  5951. Here UntracedPtr is defined as the Modula-2 pointer, hence all variables of 
  5952. that type will not be traced by garbage collector. 
  5953.  
  5954. The direct language specification placed after the name of a field, constant, 
  5955. type or variable points out that the name of the object will be treated 
  5956. according to the rules of the specified language. 
  5957.  
  5958. TYPE
  5959.   Rec ["C"] = RECORD
  5960.     name ["C"]: INTEGER;
  5961.   END;
  5962.  
  5963. CONST pi ["C"] = 3.14159;
  5964.  
  5965. VAR buffer[]["C"]: POINTER TO INTEGER;
  5966.  
  5967. As in ISO Modula-2, an address may be specified for a variable, the empty 
  5968. brackets are required to set the language. 
  5969.  
  5970. A procedure name is treated according to the language of procedure decralation, 
  5971. i.e. in the following declaration: 
  5972.  
  5973. PROCEDURE ["C"] Foo;
  5974.  
  5975. both the procedure type and procedure name will be treated according to the C 
  5976. language rules. Note: if you are using C++ compiler, the Foo function should be 
  5977. declared with C name mangling style. See your C++ manuals for further 
  5978. information. 
  5979.  
  5980.  
  5981. ΓòÉΓòÉΓòÉ 10.3. Relaxation of compatibility rules ΓòÉΓòÉΓòÉ
  5982.  
  5983. The compiler performs all semantic checks for an object or type according to 
  5984. its language specifications. Any object declared as that of Modula-2 or 
  5985. Oberon-2 will satisfy Modula-2 or Oberon-2 compatibility rules respectively. 
  5986. The compiler uses relaxed compatibility rules for objects and types declared as 
  5987. "C", "Pascal", "StdCall" and "SysCall". 
  5988.  
  5989.      Assignment compatibility 
  5990.      Parameter compatibility 
  5991.      Ignoring function result 
  5992.  
  5993.  
  5994. ΓòÉΓòÉΓòÉ 10.3.1. Assignment compatibility ΓòÉΓòÉΓòÉ
  5995.  
  5996. Two ponter type objects are considered assignment compatible, if 
  5997.  
  5998.      they are of the same Modula-2 or Oberon-2 type. 
  5999.  
  6000.      at least one of their types is declared as "C", "Pascal", "StdCall", or 
  6001.       "SysCall" and their base types are the same. 
  6002.  
  6003.   VAR
  6004.     x: POINTER TO T;
  6005.     y: POINTER TO T;
  6006.     z: POINTER ["C"] TO T;
  6007.   BEGIN
  6008.     x := y;       -- error
  6009.     y := z;       -- ok
  6010.     z := y;       -- ok
  6011.  
  6012.  
  6013. ΓòÉΓòÉΓòÉ 10.3.2. Parameter compatibility ΓòÉΓòÉΓòÉ
  6014.  
  6015. For procedures declared as "C", "Pascal", "StdCall", or "SysCall" the type 
  6016. compatibility rules for parameters are significantly relaxed. If a formal 
  6017. parameter is of the type declared as POINTER TO T, the actual parameter can be 
  6018. of any of the following types: 
  6019.  
  6020.      the same type. This is the only case for regular Modula-2/Oberon-2 
  6021.       procedures. 
  6022.  
  6023.      another type declared as POINTER TO T 
  6024.  
  6025.      any array type which elements is of type T. In this case the address of a 
  6026.       first array element is passed, as it is done in C. 
  6027.  
  6028.      the type T itself, if T is a record type. In this case the address of a 
  6029.       record is passed. 
  6030.  
  6031.  This relaxation in conjunction with the SYSTEM.REF function procedure 
  6032.  simplifies the Modula-2/Oberon-2 calls to C libraries and the target operating 
  6033.  system API while preserving the advantages of the type checking mechanism 
  6034.  provided by these languages. 
  6035.  Example 
  6036.  
  6037.   TYPE
  6038.     Str = POINTER TO CHAR;
  6039.     Rec = RECORD ... END;
  6040.     Ptr = POINTER TO Rec;
  6041.  
  6042.   PROCEDURE ["C"] Foo(s: Str); ... END Foo;
  6043.   PROCEDURE ["C"] Bar(p: Ptr);  ... END Bar;
  6044.  
  6045.   VAR
  6046.     s: Str;
  6047.     a: ARRAY [0..5] OF CHAR;
  6048.     p: POINTER TO ARRAY OF CHAR;
  6049.     R: Rec;
  6050.     A: ARRAY [0..20] OF REC;
  6051.     P: POINTER TO REC;
  6052.  
  6053.     Foo(s);   (* allowed - the same type *)
  6054.     Foo(a);   (* allowed for the "C" procedure *)
  6055.     Foo(p^);  (* allowed for the "C" procedure *)
  6056.     Bar(R);   (* the same as Bar(SYSTEM.REF(R)); *)
  6057.     Bar(A);   (* allowed for the "C" procedure *)
  6058.     Bar(P);   (* allowed for the "C" procedure *)
  6059.  
  6060.  
  6061. ΓòÉΓòÉΓòÉ 10.3.3. Ignoring function result ΓòÉΓòÉΓòÉ
  6062.  
  6063. It is a standard practice in C programming to ignore a result of a function 
  6064. call. Some standard library functions are designed taking this practice into 
  6065. account. E.g. the string copy function gets a destination string as a variable 
  6066. parameter (in terms of Modula-2) and returns a pointer to it: 
  6067.  
  6068. extern char *strcpy(char *, const char *);
  6069.  
  6070. In many cases, the result of the strcpy function call is ignored. 
  6071.  
  6072. The XDS compilers allow one to ignore the results of functions, defined as "C", 
  6073. "Pascal" or "StdCall". Thus, the function strcpy defined in the string.def 
  6074. foreign definition module as 
  6075.  
  6076. PROCEDURE ["C"] strcpy(VAR d: ARRAY OF CHAR;
  6077.                            s: ARRAY OF CHAR): ADDRESS;
  6078.  
  6079. can be used as a proper procedure or as function procedure: 
  6080.  
  6081.   strcpy(d,s);
  6082.   ptr:=strcpy(d,s);
  6083.  
  6084.  
  6085. ΓòÉΓòÉΓòÉ 10.4. Interfacing to C ΓòÉΓòÉΓòÉ
  6086.  
  6087. A special attention was taken in XDS to provide a proper interface to other 
  6088. languages, primarily to the C language. The main goal is to provide an access 
  6089. to the existing software. Foreign definition modules provide definitions which 
  6090. allow the standard libraries to be directly accessed. 
  6091.  
  6092.      Foreign definition module 
  6093.      External procedures specification 
  6094.  
  6095.  
  6096. ΓòÉΓòÉΓòÉ 10.4.1. Foreign definition module ΓòÉΓòÉΓòÉ
  6097.  
  6098. The direct language specification [n] can appear immediately after keywords 
  6099. DEFINITION MODULE (See Direct language specification). This has an effect that 
  6100. all objects defined in the module will be translated according to the 
  6101. correspondent language rules. Therefore, a direct language specification for 
  6102. each object is not necessary. 
  6103.  
  6104. Several options are often used in foreign definition modules. Note: options 
  6105. CSTDLIB and NOHEADER are meaningful for the translators to C only. 
  6106. Example 
  6107.  
  6108. <*+ M2EXTENSIONS *>
  6109. <*+ CSTDLIB *>      (* C standard library *)
  6110. <*+ NOHEADER *>     (* we already have header file *)
  6111. DEFINITION MODULE ["C"] string;
  6112.  
  6113. IMPORT SYSTEM;
  6114.  
  6115. PROCEDURE strlen(s: ARRAY OF CHAR): SYSTEM.size_t;
  6116. PROCEDURE strcmp(s1: ARRAY OF CHAR;
  6117.                  s2: ARRAY OF CHAR): SYSTEM.int;
  6118. END string.
  6119.  
  6120. If you are going to design your own foreign definition module, it will be 
  6121. usefull to take the following considerations into accout: 
  6122.  
  6123.      If you are developing an interface to the existing header file, use 
  6124.       NOHEADER option to disable the generation of header file. This option is 
  6125.       meaningful for the translators only. 
  6126.  
  6127.     
  6128.  
  6129.       If the header file is a standard header file, use the CSTDLIB option. 
  6130.       This option is meaningful for the translators only. 
  6131.  
  6132.      Use the special SYSTEM types int, unsigned, size_t and void for 
  6133.       corresponding C types. 
  6134.  
  6135.      A parameter of type T * should be replaced to the ARRAY OF T parameter, 
  6136.       if only arrays are passed to this parameter, otherwise use POINTER TO T. 
  6137.  
  6138.  Definition modules for the ANSI C libraries (stdio.def, string.def, etc) can 
  6139.  be used as tutorial examples. 
  6140.  
  6141.  
  6142. ΓòÉΓòÉΓòÉ 10.4.2. External procedures specification ΓòÉΓòÉΓòÉ
  6143.  
  6144. In some cases it may be desirable not to write a foreign definition module but 
  6145. to use some C functions directly. The XDS compilers allow a function to be 
  6146. declared as external. 
  6147.  
  6148. The declaration of an external procedure consists of a procedure header only. 
  6149. The procedure name in the header is prefixed by the symbol "/". 
  6150.  
  6151. PROCEDURE ["C"] / putchar(ch: SYSTEM.int): SYSTEM.int;
  6152.  
  6153.  
  6154. ΓòÉΓòÉΓòÉ 11. Libraries ΓòÉΓòÉΓòÉ
  6155.  
  6156. The following sets of libraries are provided with the compilers: 
  6157.  
  6158.      ISO standard Modula-2 libraries (ISO Standard Modula-2 libraries) 
  6159.  
  6160.      A subset of libraries defined in PIM (PIM standard libraries) 
  6161.  
  6162.      Utility libraries (Utility libraries) 
  6163.  
  6164.      A subset of Oberon-2 Oakwood standard libraries (Oberon-2 Oakwood 
  6165.       libraries) 
  6166.  
  6167.      Interface to Oberon-2 run-time support (The oberonRTS module) 
  6168.  
  6169.  All these libraries can be used with both Modula-2 and Oberon-2 compilers. 
  6170.  Some libraries are written in Oberon-2, others in Modula-2. If a program 
  6171.  consists of a mix of Oberon-2 and Modula-2 modules, two memory managers are in 
  6172.  use. In rare cases it can lead to the problem with memory allocation or 
  6173.  deallocation. A special care was taken to eliminate this problem (See Memory 
  6174.  management). 
  6175.  
  6176.      ISO Standard Modula-2 libraries 
  6177.      PIM standard libraries 
  6178.      Utility libraries 
  6179.      Oberon-2 Oakwood libraries 
  6180.      Standard C library definitions 
  6181.  
  6182.  
  6183. ΓòÉΓòÉΓòÉ 11.1. ISO Standard Modula-2 libraries ΓòÉΓòÉΓòÉ
  6184.  
  6185. It is our aim to provide the full set of ISO Modula-2 libraries. However, not 
  6186. all libraries may be included in the current release (See Chapter 
  6187. Implementation limitations and restrictions). System libraries are described in 
  6188. Chapter XDS Modula-2. 
  6189.  
  6190. This section does not aim at full description of ISO libraries. All libraries 
  6191. are divided into groups. A brief description and few samples are provided for 
  6192. each group. For further information refer to the corresponding definition 
  6193. modules. 
  6194.  
  6195.      Input/output library 
  6196.      Reading and writing via default channels 
  6197.      Reading and writing data 
  6198.      Device modules 
  6199.      Low-level IO modules 
  6200.      String conversions 
  6201.      Mathematical libraries 
  6202.      Processes and Semaphores 
  6203.      Other libraries 
  6204.  
  6205.  
  6206. ΓòÉΓòÉΓòÉ 11.1.1. Input/output library ΓòÉΓòÉΓòÉ
  6207.  
  6208. The IO library allows one to read and write the data streams over one or more 
  6209. channels. Channels are connected to the source of input data, or to destination 
  6210. of output data, known as devices. A set of devices can be extended. 
  6211.  
  6212. A group of modules is provided to operate on the default input and output 
  6213. channel (Reading and writing via default channels). Another group of modules 
  6214. provide facilities to operate on channels specified explicitly by a parameter 
  6215. (Reading and writing data). The device modules provide facilities to get a 
  6216. channel connected to a source (Device modules). The primitive 
  6217. device-independent operations are provided by the module IOChan; the module 
  6218. IOLink allows specialized device module to be implemented (See Low-level IO 
  6219. modules). 
  6220.  
  6221.  
  6222. ΓòÉΓòÉΓòÉ 11.1.2. Reading and writing via default channels ΓòÉΓòÉΓòÉ
  6223.  
  6224. The following modules provide procedures that operate via default input and 
  6225. output channels and do not take a parameter which identifies a channel: 
  6226.  
  6227. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6228.  IOConsts   Types and constants for IO modules
  6229.  
  6230.  SLongIO    LONGREAL numbers IO operations
  6231.  
  6232.  SRawIO     Raw IO operations (no conversion or interpretation)
  6233.  
  6234.  SRealIO    REAL numbers IO operations
  6235.  
  6236.  SResultIO  Read results for the default input channel
  6237.  
  6238.  STextIO    Character and string types IO operations
  6239.  
  6240.  SWholeIO   Whole numbers IO operations
  6241. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6242.  
  6243. The module STextIO resembles the well-known InOut library. The Hello, World 
  6244. program is implemented in the following example: 
  6245.  
  6246. MODULE Hello;
  6247.  
  6248. IMPORT  STextIO;
  6249.  
  6250. BEGIN
  6251.   STextIO.WriteString('Hello, World!');
  6252.   STextIO.WriteLn;
  6253. END Hello.
  6254.  
  6255. The modules SWholeIO, SRealIO, SLongIO provides facilities for the input and 
  6256. output of whole and real numbers in a decimal form using text operations on a 
  6257. channel. 
  6258.  
  6259. PROCEDURE Print(stage: CARDINAL; val: REAL);
  6260. BEGIN
  6261.   STextIO.WriteString("On stage");
  6262.   SWholeIO.WriteCard(stage,0);
  6263.   STextIO.WriteString(" the value is equal to ");
  6264.   SRealIO.WriteReal(val,15);
  6265.   STextIO.WriteLn;
  6266. END Print;
  6267.  
  6268. The module SIOResult allows one to determine whether the last input operation 
  6269. from a default input channel succeed. Text operations produce or consume data 
  6270. streams as a sequence of characters and line marks. The text input procedures 
  6271. (such as ReadString never remove a line mark from the input stream. The 
  6272. procedure SkipLine should be used to pass a line mark. 
  6273.  
  6274. The Copy procedure reads strings from the input channel and copies them to the 
  6275. output channel. 
  6276.  
  6277. PROCEDURE Copy;
  6278.   VAR s: ARRAY [0..63] OF CHAR;
  6279. BEGIN
  6280.   LOOP
  6281.     STextIO.ReadString(s);
  6282.     CASE SIOResult.ReadResult() OF
  6283.      |SIOResult.allRight:
  6284.         STextIO.WriteString(s);
  6285.      |SIOResult.endOfLine:
  6286.         STextIO.SkipLine;
  6287.         STextIO.WriteLn;
  6288.      |SIOResult.endOfInput:
  6289.         EXIT
  6290.     END;
  6291.   END;
  6292. END Copy;
  6293.  
  6294. No procedure is provided to get the result of a `write' operation. Device 
  6295. errors are reported by raising an exception (See module IOChan). 
  6296.  
  6297.  
  6298. ΓòÉΓòÉΓòÉ 11.1.3. Reading and writing data ΓòÉΓòÉΓòÉ
  6299.  
  6300. For all modules in this group a channel is specified by an actual parameter of 
  6301. the type IOChan.ChanId. 
  6302.  
  6303. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6304.  IOResult  Read results for specified channels
  6305.  
  6306.  LongIO    LONGREAL numbers IO operations
  6307.  
  6308.  RawIO     Raw IO operations (no conversion or interpretation)
  6309.  
  6310.  RealIO    REAL numbers IO operations
  6311.  
  6312.  TextIO    Character and string types IO operations
  6313.  
  6314.  WholeIO   Whole numbers IO operations
  6315. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6316.  
  6317. The following procedure copies an input channel to an output channel byte by 
  6318. byte: 
  6319.  
  6320. PROCEDURE CopyChars(in,out: IOChan.ChanId);
  6321.   VAR ch: CHAR;
  6322. BEGIN
  6323.   LOOP
  6324.     TextIO.ReadChar(in,ch);
  6325.     CASE IOResult.ReadResult(in) OF
  6326.      |IOResult.allRight:
  6327.         TextIO.WriteChar(out,ch);
  6328.      |IOResult.endOfLine:
  6329.         TextIO.SkipLine(in);
  6330.         TextIO.WriteLn(out);
  6331.      |IOResult.endOfInput:
  6332.         EXIT
  6333.     END;
  6334.   END;
  6335. END CopyChars;
  6336.  
  6337.  
  6338. ΓòÉΓòÉΓòÉ 11.1.4. Device modules ΓòÉΓòÉΓòÉ
  6339.  
  6340. The device modules allows to get a channel connected to a stream, a file, 
  6341. program arguments and to default channels. 
  6342.  
  6343. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6344.  ChanConsts   Common types and values for channel open requests and results
  6345.  
  6346.  ProgramArgs  Access to program arguments
  6347.  
  6348.  RndFile      Random access files
  6349.  
  6350.  SeqFile      Rewindable sequential files
  6351.  
  6352.  StdChans     Access to standard and default channels
  6353.  
  6354.  StreamFile   Independent sequential data streams
  6355. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6356.  
  6357. In the following example a channel connected to a rewindable file is opened: 
  6358.  
  6359. MODULE Example;
  6360.  
  6361. IMPORT  SeqFile, STextIO, TextIO;
  6362.  
  6363. CONST flags = SeqFile.text + SeqFile.old;
  6364.  
  6365. VAR
  6366.   cid: SeqFile.ChanId;
  6367.   res: SeqFile.OpenResults;
  6368.   i  : CARDINAL;
  6369.  
  6370. BEGIN
  6371.   SeqFile.OpenWrite(cid,"example.dat",flags,res);
  6372.   IF res = SeqFile.opened THEN
  6373.     FOR i:=0 TO 9 DO
  6374.       TextIO.WriteString(cid,"Hello");
  6375.       TextIO.WriteLn(cid);
  6376.     END;
  6377.     SeqFile.Close(cid);
  6378.   ELSE
  6379.     STextIO.WriteString("Open error");
  6380.     STextIO.WriteLn;
  6381.   END;
  6382. END Example.
  6383.  
  6384. The module StdChans allows one to get channels already open to sources and 
  6385. destinations of standard input, standard output and standard error output. 
  6386. Default channels initially corresponds to the standard channels, but their 
  6387. values may be changed to redirect input or output. 
  6388.  
  6389. PROCEDURE RedirectOutput(cid: StdChans.ChanId);
  6390. BEGIN
  6391. (* writing to the current default channel: *)
  6392.   STextIO.WriteString("Redirecting output...");
  6393.   STextIO.WriteLn;
  6394. (* redirecting output: *)
  6395.   StdChans.SetOutChan(cid);
  6396. END RedirectOutput;
  6397.  
  6398. After the call of RedirectOutput(cid) all subsequent output via modules 
  6399. STextIO, SWholeIO, etc will be written to the channel cid. To restore output 
  6400. call 
  6401.  
  6402.   StdChans.SetOutChan(StdChans.StdOutChan());
  6403.  
  6404. The module ProgramArgs provides a channel to access program's arguments. The 
  6405. following program prints all its arguments. 
  6406.  
  6407. MODULE Args;
  6408.  
  6409. IMPORT ProgramArgs, TextIO, STextIO;
  6410.  
  6411. VAR
  6412.   str: ARRAY [0..255] OF CHAR;
  6413.   cid: ProgramArgs.ChanId;
  6414.  
  6415. BEGIN
  6416.   cid:=ProgramArgs.ArgChan();
  6417.   WHILE ProgramArgs.IsArgPresent() DO
  6418.     TextIO.ReadToken(cid,str);
  6419.     (* Note: read result test is omitted *)
  6420.     STextIO.WriteString(str); STextIO.WriteLn;
  6421.   END;
  6422. END Args.
  6423.  
  6424.  
  6425. ΓòÉΓòÉΓòÉ 11.1.5. Low-level IO modules ΓòÉΓòÉΓòÉ
  6426.  
  6427. Two low-level modules are described in this section. The module IOChan defines 
  6428. the type ChanId that is used to identify channels and provides a set of 
  6429. procedures forming the channel's interface in a device-independent manner. 
  6430.  
  6431. The module IOLink provides facilities that allow one to define new device 
  6432. modules. Let us implement an encryption channel, i.e. a channel that encrypts 
  6433. all information that is written to it. To make the encryption 
  6434. device-independent we need a channel for input/output operations. 
  6435.  
  6436. In the following example a sketch of the encryption device module is shown. 
  6437.  
  6438. DEFINITION MODULE EncryptChan;
  6439.  
  6440. IMPORT IOChan, ChanConsts;
  6441.  
  6442. TYPE
  6443.   ChanId = IOChan.ChanId;
  6444.   OpenResults = ChanConsts.OpenResults;
  6445.  
  6446. PROCEDURE Connect(VAR cid: ChanId;
  6447.                        io: ChanId;
  6448.                   VAR res: OpenResults);
  6449. (* Attempts to open an encryption channel. All I/O
  6450.    operations will be made through "io" channel.
  6451. *)
  6452.  
  6453. PROCEDURE Close(VAR cid: ChanId);
  6454. (* Closes the channel. *)
  6455.  
  6456. END EncryptChan.
  6457.  
  6458. Values of the type DeviceId are used to identify device modules. By calling the 
  6459. procedure DeviceTablePtrValue, a device module can obtain a pointer to a device 
  6460. table for the channel. Each channel has it own copy of a device table. A device 
  6461. table contains a field in which the device module can store private data. In 
  6462. our example, the io channel will be stored in this field. The device table also 
  6463. serves as a method table (or virtual function table) in object-oriented 
  6464. languages. It contains the procedure variables for each device procedure. All 
  6465. fields are initialized by the call of MakeChan procedure. A device module has 
  6466. to assign its own device procedures to the fields of a device table. See the 
  6467. Connect procedure below. 
  6468.  
  6469. IMPLEMENTATION MODULE EncryptChan;
  6470.  
  6471. IMPORT IOChan, IOLink, ChanConsts, SYSTEM;
  6472.  
  6473. (* "did" is used to identify the channel's kind: *)
  6474. VAR did: IOLink.DeviceId;
  6475.  
  6476. PROCEDURE EncryptChar(from: SYSTEM.ADDRESS;
  6477.                          i: CARDINAL;
  6478.                     VAR ch: CHAR);
  6479. BEGIN
  6480.   ch:='a'; (* very simple encryption :-) *)
  6481. END EncryptChar;
  6482.  
  6483. PROCEDURE TextWrite(x: IOLink.DeviceTablePtr;
  6484.                  from: SYSTEM.ADDRESS;
  6485.                   len: CARDINAL);
  6486.   VAR i: CARDINAL;
  6487.      ch: CHAR;
  6488.     cid: IOChan.ChanId;
  6489. BEGIN
  6490.   (* get the channel id *)
  6491.   cid:=SYSTEM.CAST(IOChan.ChanId,x^.cd);
  6492.   FOR i:=0 TO len-1 DO
  6493.     (* encrypt i-th character *)
  6494.     EncryptChar(from,i,ch);
  6495.     (* write an encrypted character *)
  6496.     IOChan.TextWrite(cid,SYSTEM.ADR(ch),1);
  6497.   END;
  6498. END TextWrite;
  6499.  
  6500. PROCEDURE Connect(VAR cid: ChanId;
  6501.                        io: ChanId;
  6502.                   VAR res: OpenResults);
  6503.   VAR x: IOLink.DeviceTablePtr;
  6504. BEGIN
  6505.   IOLink.MakeChan(did,cid);
  6506.   IF cid = IOChan.InvalidChan() THEN
  6507.     res:=ChanConsts.outOfChans
  6508.   ELSE
  6509.     (* get a pointer to the device table *)
  6510.     x:=IOLink.DeviceTablePtrValue(cid,did,
  6511.                        IOChan.notAvailable,"");
  6512.     (* store the channel id *)
  6513.     x^.cd:=SYSTEM.CAST(SYSTEM.ADDRESS,io);
  6514.     x^.doTextWrite:=TextWrite;
  6515.     (* ... *)
  6516.   END;
  6517. END Connect;
  6518.  
  6519. PROCEDURE Close(VAR cid: ChanId);
  6520. BEGIN
  6521.   IOLink.UnMakeChan(did,cid);
  6522. END Close;
  6523.  
  6524. BEGIN
  6525.   IOLink.AllocateDeviceId(did);
  6526. END EncryptChan.
  6527.  
  6528. The module EncryptChan can be used as any standard device module. 
  6529.  
  6530.  
  6531. ΓòÉΓòÉΓòÉ 11.1.6. String conversions ΓòÉΓòÉΓòÉ
  6532.  
  6533. The string conversion library admits the conversion of the values of numeric 
  6534. data types to and from the character string representation. It contains the 
  6535. following modules: 
  6536.  
  6537. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6538.  ConvTypes  Common types used in the string conversion modules
  6539.  
  6540.  LongConv   Low-level LONGREAL/string conversions
  6541.  
  6542.  LongStr    LONGREAL/string conversions
  6543.  
  6544.  RealConv   Low-level REAL/string conversions
  6545.  
  6546.  RealStr    REAL/string conversions
  6547.  
  6548.  WholeConv  Low-level whole number/string conversions
  6549.  
  6550.  WholeStr   Whole number/string conversions
  6551. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6552.  
  6553. The module ConvTypes defines the enumeration type ConvResults. It also defines 
  6554. the types ScanClass and ScanState to use in the low-level conversion modules. 
  6555.  
  6556. The low-level conversion modules allow to control lexical scanning of character 
  6557. sequences. For example, the WholeConv module implements procedures ScanInt and 
  6558. ScanCard representing the start state for a finite state scanner for signed and 
  6559. unsigned whole numbers. In the following example the procedure ScanInt is used 
  6560. to locate a position of the first character in a string which is not a part of 
  6561. an integer. 
  6562.  
  6563. PROCEDURE SkipInt(str: ARRAY OF CHAR;
  6564.               VAR pos: CARDINAL);
  6565.   VAR len: CARDINAL;
  6566.     state: ConvTypes.ConvState;
  6567.     class: ConvTypes.ConvClass;
  6568. BEGIN
  6569.   pos:=0; len:=LENGTH(str);
  6570.   state:=WholeConv.ScanInt;
  6571.   WHILE pos < len DO
  6572.     state(str[pos],class,state);
  6573.     IF   (class = WholeConv.invalid)
  6574.       OR (class = WholeConv.terminator)
  6575.     THEN
  6576.       RETURN
  6577.     END;
  6578.     INC(pos);
  6579.   END;
  6580. END SkipInt;
  6581.  
  6582.  
  6583. ΓòÉΓòÉΓòÉ 11.1.7. Mathematical libraries ΓòÉΓòÉΓòÉ
  6584.  
  6585. The following modules constitute a mathematical library: 
  6586.  
  6587. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6588.  ComplexMath      Mathematical functions for the type COMPLEX
  6589.  
  6590.  LongComplexMath  Mathematical functions for the type LONGCOMPLEX
  6591.  
  6592.  LongMath         Mathematical functions for the type LONGREAL
  6593.  
  6594.  RealMath         Mathematical functions for the type REAL
  6595. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6596.  
  6597.  
  6598. ΓòÉΓòÉΓòÉ 11.1.8. Processes and Semaphores ΓòÉΓòÉΓòÉ
  6599.  
  6600. The following modules concurrent algorithms to be expressed using processes: 
  6601.  
  6602. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6603.  Processes   Provides process creation and manipulation facilities.
  6604.  
  6605.  Semaphores  Provides mutual exclusion facilities for use by processes.
  6606. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6607.  
  6608. Example 
  6609.  
  6610. MODULE Test;
  6611.  
  6612. IMPORT Processes, Semaphores, STextIO;
  6613.  
  6614. VAR
  6615.   sig : Semaphores.SEMAPHORE;
  6616.   prs : Processes.ProcessId;
  6617.   main: Processes.ProcessId;
  6618.  
  6619. PROCEDURE Proc;
  6620. BEGIN
  6621.   STextIO.WriteString('Proc 1'); STextIO.WriteLn;
  6622.   Semaphores.Claim(sig); (* suspend until released *)
  6623.   STextIO.WriteString('Proc 2'); STextIO.WriteLn;
  6624.   Processes.StopMe;
  6625. END Proc;
  6626.  
  6627. BEGIN
  6628.   STextIO.WriteString('Main 1'); STextIO.WriteLn;
  6629.   Semaphores.Create(sig,0);
  6630.   main:=Processes.Me();
  6631.   Processes.Start(Proc,40000,Processes.UrgencyOf(main)+1,NIL,prs);
  6632.   STextIO.WriteString('Main 2'); STextIO.WriteLn;
  6633.   Semaphores.Release(sig);
  6634.   STextIO.WriteString('Main 3'); STextIO.WriteLn;
  6635.   Processes.StopMe;
  6636. END Test.
  6637.  
  6638.  
  6639. ΓòÉΓòÉΓòÉ 11.1.9. Other libraries ΓòÉΓòÉΓòÉ
  6640.  
  6641. In this section we list the ISO modules that do not belong to any of the above 
  6642. groups: 
  6643.  
  6644. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6645.  CharClass  provides predicates to test a value of a character type
  6646.  
  6647.  Storage    Facilities for allocating and deallocating storage
  6648.  
  6649.  Strings    Facilities for string manipulation
  6650.  
  6651.  SysClock   Access to a system clock
  6652. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6653.  
  6654.  
  6655. ΓòÉΓòÉΓòÉ 11.2. PIM standard libraries ΓòÉΓòÉΓòÉ
  6656.  
  6657. The following libraries defined in PIM are provided: 
  6658.  
  6659. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6660.  InOut      general-purpose IO operations
  6661.  
  6662.  LongInOut  LONGREAL numbers IO operations
  6663.  
  6664.  MathLib0   mathematical functions
  6665.  
  6666.  RealInOut  REAL numbers IO operations
  6667.  
  6668.  Terminal   computer's terminal IO operations
  6669. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6670.  
  6671. The library LongInOut (similar to RealInOut is not described in PIM. All PIM 
  6672. libraries are implemented on a basis of the ISO library. Since PIM Storage 
  6673. library is not compatible with the corresponding ISO library, it is omitted. 
  6674.  
  6675.  
  6676. ΓòÉΓòÉΓòÉ 11.3. Utility libraries ΓòÉΓòÉΓòÉ
  6677.  
  6678. Starting from XDS v2.0 those modules that are portable between all versions of 
  6679. XDS on all platforms are included in the utility library. If you use ISO 
  6680. library, your program may be portable to any ISO compatible Modula-2 compiler. 
  6681. However, there are some essential omissions in the ISO library. The utility 
  6682. library is aimed at taking away some of those omissions. 
  6683.  
  6684. Some library modules are written in Oberon-2, others in Modula-2. In general 
  6685. any library can be used from both languages. However, do not forget that Oberon 
  6686. modules use implicit memory deallocation scheme and require garbage collection 
  6687. (See also Modula-2 and Oberon-2). 
  6688.  
  6689. The following modules of an utility library are provided (implementation 
  6690. language is pointed out in parentheses): 
  6691.  
  6692. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6693.  FileName  (M2)  Creating and parsing file names
  6694.  
  6695.  FileSys   (M2)  Common file operations
  6696.  
  6697.  FormOut   (M2)  Generic module for formatting output
  6698.  
  6699.  FormStr   (M2)  Formatting output to strings
  6700.  
  6701.  ProgEnv   (M2)  Access to program environment
  6702.  
  6703.  DStrings  (O2)  Dynamic strings
  6704.  
  6705.  FilePath  (O2)  File search operations
  6706.  
  6707.  RegComp   (O2)  Regular expressions
  6708. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6709.  
  6710.      The FileName module 
  6711.      The FileSys module 
  6712.      The FormOut module 
  6713.      The FormStr module 
  6714.      The ProgEnv module 
  6715.      The DStrings module 
  6716.      The FilePath module 
  6717.      The RegComp module 
  6718.  
  6719.  
  6720. ΓòÉΓòÉΓòÉ 11.3.1. The FileName module ΓòÉΓòÉΓòÉ
  6721.  
  6722. The module provides operations for parsing and constructing file names. A file 
  6723. name consists of three parts: the directory, name and extension. 
  6724.  
  6725. All the procedures that construct a string value (Get, GetDir, GetName, GetExt, 
  6726. Convert, Create), have the property that if the length of the constructed 
  6727. string value exceeds the capacity of the variable parameter, a truncated value 
  6728. is assigned. If the length of the constructed string value is less than the 
  6729. capacity of the variable parameter, a string terminator is appended. 
  6730.  
  6731.      Parsing file names 
  6732.      Format - File name format record 
  6733.      GetFormat - Get file name format 
  6734.      Get* - Get file name parts 
  6735.      File name construction 
  6736.      Convert - Convert String to File Name 
  6737.      ConvertExt - Convert File Name Extension 
  6738.      Length - Calculate File Name Length 
  6739.      Create - Create File Name 
  6740.      Example 
  6741.  
  6742.  
  6743. ΓòÉΓòÉΓòÉ 11.3.1.1. Parsing file names ΓòÉΓòÉΓòÉ
  6744.  
  6745. The GetFormat procedure returns the position and length of file name parts. 
  6746.  
  6747.  
  6748. ΓòÉΓòÉΓòÉ 11.3.1.2. Format - File name format record ΓòÉΓòÉΓòÉ
  6749.  
  6750. TYPE
  6751.   Format = RECORD
  6752.     ok: BOOLEAN;
  6753.     (* directory position and length: *)
  6754.     dirPos, dirLen : CARDINAL;
  6755.     (* name position and length: *)
  6756.     namePos,nameLen: CARDINAL;
  6757.     (* extension position and length: *)
  6758.     extPos, extLen : CARDINAL;
  6759.   END;
  6760.  
  6761.  
  6762. ΓòÉΓòÉΓòÉ 11.3.1.3. GetFormat - Get file name format ΓòÉΓòÉΓòÉ
  6763.  
  6764. PROCEDURE GetFormat(str: ARRAY OF CHAR; VAR f: Format);
  6765.  
  6766. Returns the format of the string. The values of all fields are undefined if 
  6767. f.ok = FALSE. 
  6768.  
  6769. The following procedures return file name part(s). 
  6770.  
  6771.  
  6772. ΓòÉΓòÉΓòÉ 11.3.1.4. Get* - Get file name parts ΓòÉΓòÉΓòÉ
  6773.  
  6774. PROCEDURE GetDir (fname: ARRAY OF CHAR;
  6775.                 VAR dir: ARRAY OF CHAR);
  6776. PROCEDURE GetName(fname: ARRAY OF CHAR;
  6777.                VAR name: ARRAY OF CHAR);
  6778. PROCEDURE GetExt (fname: ARRAY OF CHAR;
  6779.                 VAR ext: ARRAY OF CHAR);
  6780. PROCEDURE Get(fname: ARRAY OF CHAR;
  6781.    VAR dir,name,ext: ARRAY OF CHAR);
  6782.  
  6783.  
  6784. ΓòÉΓòÉΓòÉ 11.3.1.5. File name construction ΓòÉΓòÉΓòÉ
  6785.  
  6786.  
  6787. ΓòÉΓòÉΓòÉ 11.3.1.6. Convert - Convert String to File Name ΓòÉΓòÉΓòÉ
  6788.  
  6789. PROCEDURE Convert(str: ARRAY OF CHAR;
  6790.             VAR fname: ARRAY OF CHAR);
  6791.  
  6792. Converts a string to a file name according to the conventions of the underlying 
  6793. file system. 
  6794.  
  6795.  
  6796. ΓòÉΓòÉΓòÉ 11.3.1.7. ConvertExt - Convert File Name Extension ΓòÉΓòÉΓòÉ
  6797.  
  6798. PROCEDURE ConvertExt(VAR ext: ARRAY OF CHAR);
  6799.  
  6800. Converts an extension according to the conventions of the underlying file 
  6801. system. 
  6802.  
  6803.  
  6804. ΓòÉΓòÉΓòÉ 11.3.1.8. Length - Calculate File Name Length ΓòÉΓòÉΓòÉ
  6805.  
  6806. PROCEDURE Length(dir,name,ext: CARDINAL): CARDINAL;
  6807.  
  6808. Using the lengths of the directory, name and extension returns an estimated 
  6809. file name length which is greater than or equal to the length of the name 
  6810. generated by the Create procedure call. 
  6811.  
  6812.  
  6813. ΓòÉΓòÉΓòÉ 11.3.1.9. Create - Create File Name ΓòÉΓòÉΓòÉ
  6814.  
  6815. PROCEDURE Create(dir,name,ext: ARRAY OF CHAR;
  6816.                     VAR fname: ARRAY OF CHAR);
  6817.  
  6818. Creates a file name from the parts. 
  6819.  
  6820.  
  6821. ΓòÉΓòÉΓòÉ 11.3.1.10. Example ΓòÉΓòÉΓòÉ
  6822.  
  6823. The following procedure can be used to change file name extension: 
  6824.  
  6825. PROCEDURE ChangeExt(VAR fname: ARRAY OF CHAR;
  6826.                        newext: ARRAY OF CHAR);
  6827.   CONST Len = 64;
  6828.   VAR
  6829.     dir,name: ARRAY [0..Len-1] OF CHAR;
  6830.     f: FileName.Format;
  6831.     len: CARDINAL;
  6832. BEGIN
  6833.   FileName.GetFormat(fname,f);
  6834.   IF NOT f.ok THEN Error("wrong format")
  6835.   ELSIF (f.dirLen > Len) OR (f.nameLen > Len) THEN
  6836.     Error("too long part");
  6837.   ELSE
  6838.     len:=FileName.Length(f.dirLen,f.nameLen,LENGTH(newext));
  6839.     IF len-1 > HIGH(fname) THEN
  6840.       Error("cannot create file name")
  6841.     ELSE
  6842.       FileName.Create(dir,name,newext,fname);
  6843.     END;
  6844.   END;
  6845. END ChangeExt;
  6846.  
  6847. When programming in Oberon-2 dynamic strings can be used to create strings of a 
  6848. required length: 
  6849.  
  6850. PROCEDURE ChangeExt(VAR fname: ARRAY OF CHAR;
  6851.                        newext: ARRAY OF CHAR);
  6852.   VAR
  6853.     dir,name: DStrings.String;
  6854.     f: FileName.Format;
  6855. BEGIN
  6856.   FileName.GetFormat(fname,f);
  6857.   IF NOT f.ok THEN Error("wrong format")
  6858.   ELSE
  6859.     NEW(dir,f.dirLen+1);
  6860.     NEW(name,f.nameLen+1);
  6861.     ...
  6862.     END;
  6863.   END;
  6864. END ChangeExt;
  6865.  
  6866.  
  6867. ΓòÉΓòÉΓòÉ 11.3.2. The FileSys module ΓòÉΓòÉΓòÉ
  6868.  
  6869. The module provides file common operations. 
  6870.  
  6871.      Exists - Is File Exist 
  6872.      ModifyTime - Return Modify Time 
  6873.      Rename - Rename File 
  6874.      Remove - Remove File 
  6875.  
  6876.  
  6877. ΓòÉΓòÉΓòÉ 11.3.2.1. Exists - Is File Exist ΓòÉΓòÉΓòÉ
  6878.  
  6879. PROCEDURE Exists(fname: ARRAY OF CHAR): BOOLEAN;
  6880.  
  6881. Returns TRUE, if file fname exists. 
  6882.  
  6883.  
  6884. ΓòÉΓòÉΓòÉ 11.3.2.2. ModifyTime - Return Modify Time ΓòÉΓòÉΓòÉ
  6885.  
  6886. PROCEDURE ModifyTime(fname: ARRAY OF CHAR;
  6887.                   VAR time: LONGCARD;
  6888.                 VAR exists: BOOLEAN);
  6889.  
  6890. Returns a file modification time; time is valid only if exists=TRUE. 
  6891.  
  6892.  
  6893. ΓòÉΓòÉΓòÉ 11.3.2.3. Rename - Rename File ΓòÉΓòÉΓòÉ
  6894.  
  6895. PROCEDURE Rename(fname,newname: ARRAY OF CHAR;
  6896.                       VAR done: BOOLEAN);
  6897.  
  6898. Renames the file fname to newname. 
  6899.  
  6900.  
  6901. ΓòÉΓòÉΓòÉ 11.3.2.4. Remove - Remove File ΓòÉΓòÉΓòÉ
  6902.  
  6903. PROCEDURE Remove(fname: ARRAY OF CHAR;
  6904.               VAR done: BOOLEAN);
  6905.  
  6906. Removes a file. 
  6907.  
  6908.  
  6909. ΓòÉΓòÉΓòÉ 11.3.3. The FormOut module ΓòÉΓòÉΓòÉ
  6910.  
  6911. The module implements a formatting output procedure which outputs its arguments 
  6912. according to the format parameter. The syntax of the format string is 
  6913. compatible with the corresponding parameter of the C procedure printf. Some 
  6914. useful format extensions are provided. 
  6915.  
  6916.      writeProc - Write Procedure Type 
  6917.      format - Formating Procedure 
  6918.      LineSeparator - Set Line Separator 
  6919.      TextSeparator - Set Line Separator 
  6920.      Examples 
  6921.  
  6922.  
  6923. ΓòÉΓòÉΓòÉ 11.3.3.1. writeProc - Write Procedure Type ΓòÉΓòÉΓòÉ
  6924.  
  6925. TYPE
  6926.   writeProc = PROCEDURE(
  6927.                 (*handle:*) SYSTEM.ADDRESS,
  6928.                 (*string:*) ARRAY OF CHAR,
  6929.                 (*length:*) INTEGER
  6930.               );
  6931.  
  6932.  
  6933. ΓòÉΓòÉΓòÉ 11.3.3.2. format - Formating Procedure ΓòÉΓòÉΓòÉ
  6934.  
  6935. PROCEDURE format(handle : SYSTEM.ADDRESS;
  6936.                  write  : writeProc;
  6937.                  fmt    : ARRAY OF CHAR;
  6938.                  linesep: CHAR;
  6939.                  args   : SYSTEM.ADDRESS;
  6940.                  size   : CARDINAL);
  6941.  
  6942. The procedure forms a string and outputs it via the write procedure parameter. 
  6943. The parameter handle is passed to the procedure write and provides a useful 
  6944. method to pass any information between the caller and the write procedure (e.g. 
  6945. output channel or something like it). The (args, size) pair denotes the address 
  6946. and size of the parameter block. The linesep parameter determines the line 
  6947. separator character sequence corresponding to "\n". Several standard values of 
  6948. the parameter are defined in the definition module: 
  6949.  
  6950. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6951.  default  default line separator for binary files
  6952.  
  6953.  text     default line separator for text files
  6954.  
  6955.  crlf     CR LF character sequence
  6956. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6957.  
  6958. If the linesep is not equal to any of the values above, its value will be used 
  6959. as a line separator. 
  6960.  
  6961. The format string has the following syntax: 
  6962.  
  6963.   Format = { character | Specifier }.
  6964.   Specifier = "%" Modifier Width
  6965.             [ "." Precision [ "." Start ] ] Base.
  6966.   Modifier = "-" | "+" | "|" | "0" | "$" | "#".
  6967.   Width = [ unsigned number | "*" ].
  6968.   Precision = [ unsigned number | "*" ].
  6969.   Start = [ unsigned number | "*" ].
  6970.   Base = "d" | "i" | "x" | "X" | "o" | "{}"
  6971.        | "f" | "g" | "e".
  6972.  
  6973. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6974.  Modifier  Meaning
  6975.  
  6976.  "-"       justifies a value to the left
  6977.  
  6978.  "+"       prints a sign for numbers (even of a non-negative)
  6979.  
  6980.  "|"       center value
  6981.  
  6982.  "0"       fills a place for numbers with "0" characters (default - filling with spaces)
  6983.  
  6984.  "$"       the same as "0"
  6985.  
  6986.  "#"       prints a base character ("H" or "B") according to the base; for "o", "x" and "X" bases only.
  6987. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6988.  
  6989. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6990.  Base  Meaning
  6991.  
  6992.  "c"   prints a character
  6993.  
  6994.  "d"   prints a value in a decimal form
  6995.  
  6996.  "e"   prints a value in a floating-point form
  6997.  
  6998.  "f"   prints a value in a fixed-point form
  6999.  
  7000.  "g"   prints a value in a fixed-point or in floating-point form depending on the value
  7001.  
  7002.  "i"   the same as "d"
  7003.  
  7004.  "o"   prints a value in an octal form
  7005.  
  7006.  "s"   prints a string
  7007.  
  7008.  "x"   prints a value in a hexadecimal form, use letters "A".."F"
  7009.  
  7010.  "X"   prints a value in a hexadecimal form, use letters "a".."f"
  7011.  
  7012.  "{}"  prints a value as a bitset, e.g. {1,3..5}
  7013. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7014.  
  7015. The procedure format converts the following pairs of symbols starting from the 
  7016. backslash (no convertion is done for strings printed using "%s" specifier): 
  7017.  
  7018. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7019.  Pair  Meaning
  7020.  
  7021.  \n    prints the line separator according to the value of the linesep parameter
  7022.  
  7023.  \r    prints CR (15C)
  7024.  
  7025.  \f    prints FF (14C)
  7026.  
  7027.  \t    prints TAB (11C)
  7028.  
  7029.  \\    prints the backslash
  7030. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7031.  
  7032.      Important notes: 
  7033.  
  7034.  Important notes: 
  7035.  
  7036.      neither the compiler nor the library checks the correspondence between 
  7037.       actual arguments and format specifications. However, unlike printf, all 
  7038.       specifiers whose arguments are not passed will be ignored. 
  7039.  
  7040.      the ISO conversion library (See String conversions) is used to output 
  7041.       numbers. 
  7042.  
  7043.      "*" in the width or precision position means that the corresponding 
  7044.       number is passed as current actual parameter. 
  7045.  
  7046.      for the "c" base the second number (precision) is a repetition factor. 
  7047.  
  7048.      for the "s" base the second number (precision) is the maximum number of 
  7049.       characters in a string to process. 
  7050.  
  7051.      for the "s" base the third number (start) specifies the start position in 
  7052.       a string to process. 
  7053.  
  7054.  
  7055. ΓòÉΓòÉΓòÉ 11.3.3.3. LineSeparator - Set Line Separator ΓòÉΓòÉΓòÉ
  7056.  
  7057. PROCEDURE LineSeparator(nl: ARRAY OF CHAR);
  7058.  
  7059. Sets the default line separator for binary files. The correct value for the 
  7060. given platform is set in the module initializaion. 
  7061.  
  7062.  
  7063. ΓòÉΓòÉΓòÉ 11.3.3.4. TextSeparator - Set Line Separator ΓòÉΓòÉΓòÉ
  7064.  
  7065. PROCEDURE TextSeparator(nl: ARRAY OF CHAR);
  7066.  
  7067. Sets the default line separator for text files. The correct value for the given 
  7068. platform is set in the module initializaion. 
  7069.  
  7070.  
  7071. ΓòÉΓòÉΓòÉ 11.3.3.5. Examples ΓòÉΓòÉΓòÉ
  7072.  
  7073. The following example shows the implementation of a procedure which produces a 
  7074. format output to an ISO channel. 
  7075.  
  7076. PROCEDURE ChanWrite(handle: SYSTEM.ADDRESS;
  7077.                     str: ARRAY OF CHAR;
  7078.                     len: INTEGER);
  7079.   VAR chan: IOChan.ChanId; pos: INTEGER;
  7080. BEGIN
  7081.   chan:=SYSTEM.CAST(IOChan.ChanId,handle);
  7082.   pos:=0;
  7083.   WHILE len > 0 DO
  7084.     IF str[pos] = ASCII.LF THEN IOChan.WriteLn
  7085.     ELSE IOChan.TextWrite(chan,SYSTEM.ADR(str[pos]),1)
  7086.     END;
  7087.     INC(pos); DEC(len);
  7088.   END;
  7089. END ChanWrite;
  7090.  
  7091. PROCEDURE Print(chan: IOChan.ChanId;
  7092.               format: ARRAY OF CHAR;
  7093.             SEQ args: SYSTEM.BYTE);
  7094. BEGIN
  7095.   FormOut.format(chan,ChanWrite,format,FormOut.text,
  7096.                  SYSTEM.ADR(args),SIZE(args));
  7097. END Print;
  7098.  
  7099. The procedure printf prints to the standard output channel: 
  7100.  
  7101. PROCEDURE printf(f: ARRAY OF CHAR; SEQ x: SYSTEM.BYTE);
  7102. BEGIN
  7103.   Print(StdChans.StdOutChan(),f,x);
  7104. END printf;
  7105.  
  7106. The procedure printf can be used in the conventional for C programmers way, 
  7107. e.g. the call 
  7108.  
  7109.   printf("%d! = %d\n",5,Factorial(5));
  7110.  
  7111. will produce the line Provided that the implementation of the procedure 
  7112. Factorial corresponds to its name. 
  7113.  
  7114.   5! = 120
  7115.  
  7116.      Examples: 
  7117.  
  7118.  Examples: 
  7119.  
  7120.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7121.    Call                       Output
  7122.  
  7123.    printf("%5.3s","abcdef")     abc
  7124.  
  7125.    printf("%-5.3s","abcdef")  abc
  7126.  
  7127.    printf("%|5.3s","abcdef")   abc
  7128.  
  7129.    printf("%..3s","abcdef")   def
  7130.  
  7131.    printf("pos=%3d",13)       pos= 13
  7132.  
  7133.    printf("%$3o",13)          015
  7134.  
  7135.    printf("%04X",33C)         001B
  7136.  
  7137.    printf("%{}",13)           {0,2..3}
  7138.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7139.  
  7140.  
  7141. ΓòÉΓòÉΓòÉ 11.3.4. The FormStr module ΓòÉΓòÉΓòÉ
  7142.  
  7143. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7144.  WARNING:  Language extensions are used in the interface of this module. All your modules importing this one may be non-portable to other compilers.
  7145. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7146.  
  7147. A string is an array of characters of an arbitrary length. The procedures 
  7148. print, append and image guarantee the presence of the string terminator (0C) in 
  7149. the resulting string. See the module FormOut for information about the format 
  7150. syntax. 
  7151.  
  7152.      print - Print to string 
  7153.      append - Append to the end of string 
  7154.      image - Print from the given position 
  7155.      iscan - Read integer in Modula-2 format 
  7156.  
  7157.  
  7158. ΓòÉΓòÉΓòÉ 11.3.4.1. print - Print to string ΓòÉΓòÉΓòÉ
  7159.  
  7160. PROCEDURE print(VAR str: ARRAY OF CHAR;
  7161.                  format: ARRAY OF CHAR;
  7162.                SEQ args: SYSTEM.BYTE);
  7163.  
  7164. Constructs a string specified by the pair (format,args) and places it into str. 
  7165.  
  7166.  
  7167. ΓòÉΓòÉΓòÉ 11.3.4.2. append - Append to the end of string ΓòÉΓòÉΓòÉ
  7168.  
  7169. PROCEDURE append( VAR str: ARRAY OF CHAR;
  7170.                    format: ARRAY OF CHAR;
  7171.                  SEQ args: SYSTEM.BYTE);
  7172.  
  7173. Appends a string specified by the pair (format,args) to the end of the string 
  7174. str. 
  7175.  
  7176.  
  7177. ΓòÉΓòÉΓòÉ 11.3.4.3. image - Print from the given position ΓòÉΓòÉΓòÉ
  7178.  
  7179. PROCEDURE image( VAR str: ARRAY OF CHAR;
  7180.                  VAR pos: LONGINT;
  7181.                   format: ARRAY OF CHAR;
  7182.                 SEQ args: SYSTEM.BYTE);
  7183.  
  7184. Places a string specified by the pair (format,args) in the string str starting 
  7185. from the position pos. After the procedure call, pos points to the 0C or to the 
  7186. position next to the end of the string. 
  7187.  
  7188.  
  7189. ΓòÉΓòÉΓòÉ 11.3.4.4. iscan - Read integer in Modula-2 format ΓòÉΓòÉΓòÉ
  7190.  
  7191. PROCEDURE iscan( VAR num: INTEGER;
  7192.                      str: ARRAY OF CHAR;
  7193.                  VAR pos: CARDINAL;
  7194.                 VAR done: BOOLEAN);
  7195.  
  7196. Reads the integer value from the string str starting from the position pos. 
  7197. After the procedure call we have: 
  7198.  
  7199. The appearance of the following table is a known problem and will be improved 
  7200. in the final release. 
  7201.  
  7202.  done  becomes TRUE, if the attempt was successful; 
  7203. pos  is the index of the first character following the number; 
  7204. num  is the read value when done=TRUE. 
  7205.  
  7206. The number may be represented in any form permissible in Modula-2. In case of 
  7207. an integer overflow done=FALSE. 
  7208.  
  7209.  
  7210. ΓòÉΓòÉΓòÉ 11.3.5. The ProgEnv module ΓòÉΓòÉΓòÉ
  7211.  
  7212. The module provides an access to the program environment. 
  7213.  
  7214.      ArgNumber - Return the number of arguments 
  7215.      GetArg - Get argument 
  7216.      ArgLength - Return length of argument 
  7217.      ProgramName - Get program name 
  7218.      ProgramNameLength - Length of program name 
  7219.      String - Get environment string 
  7220.      StringLength - Return environment string length 
  7221.      Example 
  7222.  
  7223.  
  7224. ΓòÉΓòÉΓòÉ 11.3.5.1. ArgNumber - Return the number of arguments ΓòÉΓòÉΓòÉ
  7225.  
  7226. PROCEDURE ArgNumber(): CARDINAL;
  7227.  
  7228. Returns the number of arguments (0 if there is no arguments). 
  7229.  
  7230.  
  7231. ΓòÉΓòÉΓòÉ 11.3.5.2. GetArg - Get argument ΓòÉΓòÉΓòÉ
  7232.  
  7233. PROCEDURE GetArg(n: CARDINAL; VAR arg: ARRAY OF CHAR);
  7234.  
  7235. Copies n-th argument to arg, or empty string if n >= ArgNumber(). 
  7236.  
  7237.  
  7238. ΓòÉΓòÉΓòÉ 11.3.5.3. ArgLength - Return length of argument ΓòÉΓòÉΓòÉ
  7239.  
  7240. PROCEDURE ArgLength(n: CARDINAL): CARDINAL;
  7241.  
  7242. Returns the length of the n-th argument (0 if n>=ArgNumber(). 
  7243.  
  7244.  
  7245. ΓòÉΓòÉΓòÉ 11.3.5.4. ProgramName - Get program name ΓòÉΓòÉΓòÉ
  7246.  
  7247. PROCEDURE ProgramName(VAR name: ARRAY OF CHAR);
  7248.  
  7249. Copies a program name to name. 
  7250.  
  7251.  
  7252. ΓòÉΓòÉΓòÉ 11.3.5.5. ProgramNameLength - Length of program name ΓòÉΓòÉΓòÉ
  7253.  
  7254. PROCEDURE ProgramNameLength(): CARDINAL;
  7255.  
  7256. Returns the length of the program name. 
  7257.  
  7258.  
  7259. ΓòÉΓòÉΓòÉ 11.3.5.6. String - Get environment string ΓòÉΓòÉΓòÉ
  7260.  
  7261. PROCEDURE String(name: ARRAY OF CHAR;
  7262.               VAR str: ARRAY OF CHAR);
  7263.  
  7264. Copies a value of the environment variable name to str (empty string if the 
  7265. variable is undefined). 
  7266.  
  7267.  
  7268. ΓòÉΓòÉΓòÉ 11.3.5.7. StringLength - Return environment string length ΓòÉΓòÉΓòÉ
  7269.  
  7270. PROCEDURE StringLength(name: ARRAY OF CHAR): CARDINAL;
  7271.  
  7272. Returns the length of the environment variable name (0 if the variable is 
  7273. undefined). 
  7274.  
  7275.  
  7276. ΓòÉΓòÉΓòÉ 11.3.5.8. Example ΓòÉΓòÉΓòÉ
  7277.  
  7278. The following procedure (in Oberon-2) prints all its arguments: 
  7279.  
  7280. PROCEDURE ShowArgs;
  7281.   VAR
  7282.     str: POINTER TO ARRAY OF CHAR;
  7283.     i,args: LONGINT;
  7284. BEGIN
  7285.   i:=0;
  7286.   args:=ProgEnv.ArgNumber();
  7287.   FOR i:=0 TO args-1 DO
  7288.     NEW(str,ProgEnv.ArgLength(i)+1);
  7289.     ProgEnv.GetArg(i,str^);
  7290.     STextIO.WriteString(str^); STextIO.WriteLn;
  7291.   END;
  7292. END ShowArgs;
  7293.  
  7294.  
  7295. ΓòÉΓòÉΓòÉ 11.3.6. The DStrings module ΓòÉΓòÉΓòÉ
  7296.  
  7297. The module DStrings (written in Oberon-2) defines a dynamic string type and 
  7298. provides some conventional operations. 
  7299.  
  7300.      String - Dynamic String Type 
  7301.      Assign - Create and Initialize String 
  7302.      Append - Append to Dynamic String 
  7303.  
  7304.  
  7305. ΓòÉΓòÉΓòÉ 11.3.6.1. String - Dynamic String Type ΓòÉΓòÉΓòÉ
  7306.  
  7307. TYPE String* = POINTER TO ARRAY OF CHAR;
  7308.  
  7309.  
  7310. ΓòÉΓòÉΓòÉ 11.3.6.2. Assign - Create and Initialize String ΓòÉΓòÉΓòÉ
  7311.  
  7312. PROCEDURE Assign*(s: ARRAY OF CHAR; VAR d: String);
  7313.  
  7314. Allocates a new string and copies from s. The resulting string always contains 
  7315. the string terminator (0X). 
  7316.  
  7317.  
  7318. ΓòÉΓòÉΓòÉ 11.3.6.3. Append - Append to Dynamic String ΓòÉΓòÉΓòÉ
  7319.  
  7320. PROCEDURE Append*(s: ARRAY OF CHAR; VAR d: String);
  7321.  
  7322. Appends the string s, extending d if necessary. The resulting string always 
  7323. contains the string terminator (0X). 
  7324.  
  7325.  
  7326. ΓòÉΓòÉΓòÉ 11.3.7. The FilePath module ΓòÉΓòÉΓòÉ
  7327.  
  7328. The module (written in Oberon-2) provides file search facilities. In the 
  7329. following procedures path is a list of directories separated by semicolons, 
  7330. e.g. 
  7331.  
  7332.   .\SYM;C:\LIB\SYM;C:\XDS\LIB\SYM;.        (MS-DOS)
  7333.   ./sym;~/lib/sym;/usr/bin/xds/sym;.       (Unix)
  7334.  
  7335.      IsSimpleName - Is just a File Name 
  7336.      Lookup - Look up File 
  7337.      UseFirst - Use First Directory 
  7338.  
  7339.  
  7340. ΓòÉΓòÉΓòÉ 11.3.7.1. IsSimpleName - Is just a File Name ΓòÉΓòÉΓòÉ
  7341.  
  7342. PROCEDURE IsSimpleName*(name: ARRAY OF CHAR): BOOLEAN;
  7343.  
  7344. Returns TRUE, if the name contains the file name only (does not contain 
  7345. directories). 
  7346.  
  7347.  
  7348. ΓòÉΓòÉΓòÉ 11.3.7.2. Lookup - Look up File ΓòÉΓòÉΓòÉ
  7349.  
  7350. PROCEDURE Lookup*(path,name: ARRAY OF CHAR;
  7351.                   VAR fname: DStrings.String;
  7352.                   VAR n: INTEGER);
  7353.  
  7354. Builds a filename using the search path. Returns: 
  7355.  
  7356. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7357.  n = -1  name is not simple (fname := name)
  7358.  
  7359.  n = 0   file is not found (the first directory is used)
  7360.  
  7361.  n > 0   file is found in the n-th directory
  7362. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7363.  
  7364.  
  7365. ΓòÉΓòÉΓòÉ 11.3.7.3. UseFirst - Use First Directory ΓòÉΓòÉΓòÉ
  7366.  
  7367. PROCEDURE UseFirst*(path,name: ARRAY OF CHAR;
  7368.                     VAR fname: DStrings.String);
  7369.  
  7370. Builds a filename using the first directory from the search path. 
  7371.  
  7372.  
  7373. ΓòÉΓòÉΓòÉ 11.3.8. The RegComp module ΓòÉΓòÉΓòÉ
  7374.  
  7375. This module (written in Oberon-2) implements a comparison of a string with 
  7376. regular expression. 
  7377.  
  7378.      Regular expressions 
  7379.      Examples of regular expressions 
  7380.      Module description 
  7381.      Expr - Regular expression 
  7382.      Compile - Compile regular expression 
  7383.      Const - Is constant expression 
  7384.      Match - Compare string with expression 
  7385.      Len - Length of substring 
  7386.      Pos - Position of substring 
  7387.      Substitute - Substitute substrings 
  7388.      Example 
  7389.  
  7390.  
  7391. ΓòÉΓòÉΓòÉ 11.3.8.1. Regular expressions ΓòÉΓòÉΓòÉ
  7392.  
  7393. A regular expression is a string which contains certain special symbols. These 
  7394. are 
  7395.  
  7396.  *         denotes an arbitrary sequence of any character, possibly empty 
  7397.            (equivalent to {\000-\377} expression) 
  7398.  
  7399.  ?         denotes an arbitrary single character; (equivalent to the 
  7400.            [\000-\377] expression) 
  7401.  
  7402.  [characters] denotes one of the named characters 
  7403.  
  7404.  {characters} denotes an arbitrary sequence of the named characters; 
  7405.  
  7406.  \char '134nnn denotes an ASCII character with an octal code nnn where n is 
  7407.            [0-7]. 
  7408.  
  7409.  &         denotes the logical operation AND; 
  7410.  
  7411.  |         denotes the logical operation OR; 
  7412.  
  7413.  ^         denotes the logical operation NOT; 
  7414.  
  7415.  (..)      sets the priority of operations; 
  7416.  
  7417.  $digit    may be attached to *, ?, [], {} and (). In the later expressions, it 
  7418.            will represent the string of symbols comparable with the 
  7419.            subexpression preceding it. 
  7420.  
  7421.  A sequence of the form a-b used within either [] or {} brackets represents all 
  7422.  ASCII characters from a to b. 
  7423.  
  7424.  If you need to use any special symbols as an ordinary symbol, you should 
  7425.  precede it by the symbol \ which suppresses its interpretation. 
  7426.  
  7427.  
  7428. ΓòÉΓòÉΓòÉ 11.3.8.2. Examples of regular expressions ΓòÉΓòÉΓòÉ
  7429.  
  7430. {0-9A-F} defines the set of hexadecimal numbers 
  7431.  
  7432. [a-zA-z_] defines a single small or capital letter or an underscore character. 
  7433.  
  7434. (({0-9A-Fa-f})$1|({a-zA-Z_})$2))$3 corresponds to both hexadecimal numbers and 
  7435. Modula-2 identifiers. The program could address a hexadecimal number by the $1 
  7436. reference, identifier by the $2 reference and both of them by the $3 reference. 
  7437.  
  7438. \\\$\{\}\[\]\*\? is equal to the string \${}[]*?. 
  7439.  
  7440.  
  7441. ΓòÉΓòÉΓòÉ 11.3.8.3. Module description ΓòÉΓòÉΓòÉ
  7442.  
  7443.  
  7444. ΓòÉΓòÉΓòÉ 11.3.8.4. Expr - Regular expression ΓòÉΓòÉΓòÉ
  7445.  
  7446. TYPE
  7447.   Expr*    = POINTER TO ExprDesc;
  7448.   ExprDesc = RECORD END;
  7449.  
  7450.  
  7451. ΓòÉΓòÉΓòÉ 11.3.8.5. Compile - Compile regular expression ΓòÉΓòÉΓòÉ
  7452.  
  7453. PROCEDURE Compile*(expr: ARRAY OF CHAR;
  7454.                 VAR reg: Expr;
  7455.                 VAR res: LONGINT);
  7456.  
  7457. Compiles a regular expression to an internal form. 
  7458.  
  7459. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7460.  Value of res  Meaning
  7461.  
  7462.  res?0         error in position ABS(res)
  7463.  
  7464.  res > 0       done
  7465. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7466.  
  7467.  
  7468. ΓòÉΓòÉΓòÉ 11.3.8.6. Const - Is constant expression ΓòÉΓòÉΓòÉ
  7469.  
  7470. PROCEDURE Const*(re: Expr): BOOLEAN;
  7471.  
  7472. Returns TRUE, if an expression does not contain wildcards. 
  7473.  
  7474.  
  7475. ΓòÉΓòÉΓòÉ 11.3.8.7. Match - Compare string with expression ΓòÉΓòÉΓòÉ
  7476.  
  7477. PROCEDURE Match*(re: Expr;
  7478.                   s: ARRAY OF CHAR;
  7479.                 pos: LONGINT): BOOLEAN;
  7480.  
  7481. Returns TRUE, if the expression matches the string s starting from the position 
  7482. pos. 
  7483.  
  7484.  
  7485. ΓòÉΓòÉΓòÉ 11.3.8.8. Len - Length of substring ΓòÉΓòÉΓòÉ
  7486.  
  7487. PROCEDURE Len*(re: Expr; n: INTEGER): LONGINT;
  7488.  
  7489. Returns the length of the substring which corresponds to $n in the last call of 
  7490. the Match procedure with the parameter re. 
  7491.  
  7492.  
  7493. ΓòÉΓòÉΓòÉ 11.3.8.9. Pos - Position of substring ΓòÉΓòÉΓòÉ
  7494.  
  7495. PROCEDURE Pos*(re: Expr; n: INTEGER): LONGINT;
  7496.  
  7497. Returns the position of the substring which corresponds to $n in the last call 
  7498. of the Match procedure with the parameter re. 
  7499.  
  7500.  
  7501. ΓòÉΓòÉΓòÉ 11.3.8.10. Substitute - Substitute substrings ΓòÉΓòÉΓòÉ
  7502.  
  7503. PROCEDURE Substitute*(re: Expr;
  7504.                      s,m: ARRAY OF CHAR;
  7505.                    VAR d: ARRAY OF CHAR);
  7506.  
  7507. The substrings of s which matched re are substituted instead of $digit into m 
  7508. and the result string is copied into d. 
  7509.  
  7510. Note: The Match(re,s,0) call should be issued and tested for success prior to a 
  7511. call to Substitute. 
  7512.  
  7513.  
  7514. ΓòÉΓòÉΓòÉ 11.3.8.11. Example ΓòÉΓòÉΓòÉ
  7515.  
  7516. After the following sequence of calls 
  7517.  
  7518.   Compile("{a-z}$1{0-9}$2",re,res);
  7519.   IF Match(re,"abcdef153",0) THEN
  7520.     Substitute(re,"abcdef153","tail: $2 head: $1",dest);
  7521.   END;
  7522.  
  7523. the dest string will contain 
  7524.  
  7525.   "tail: 153 head: abcdef"
  7526.  
  7527.  
  7528. ΓòÉΓòÉΓòÉ 11.4. Oberon-2 Oakwood libraries ΓòÉΓòÉΓòÉ
  7529.  
  7530. The Oakwood Guidelines (See Chapter XDS Oberon-2) specifies a set of libraries 
  7531. that should be provided with all Oberon implementations. The current XDS 
  7532. release does not contain all libraries. The following libraries are currently 
  7533. available: 
  7534.  
  7535. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7536.  In         input from a standard stream
  7537.  
  7538.  MathR      mathematical functions for REAL
  7539.  
  7540.  MathL      mathematical functions for LONGREAL
  7541.  
  7542.  MathC      mathematical functions for COMPLEX
  7543.  
  7544.  MathLC     mathematical functions for LONGCOMPLEX
  7545.  
  7546.  Out        output to a standard stream
  7547.  
  7548.  O2Strings  simple manipulations for strings
  7549. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7550.  
  7551. The Math library is renamed to MathR, because it coincides with the ANSI C math 
  7552. library interface (See Standard C library definitions). The complex types and, 
  7553. hence, MathC and MathLC modules may be not available for other Oberon 
  7554. implementations (See also Oakwood numeric extensions). 
  7555.  
  7556. The Strings library is renamed to O2Strings, since it is not compatible with 
  7557. the correspondent ISO library. 
  7558.  
  7559.  
  7560. ΓòÉΓòÉΓòÉ 11.5. Standard C library definitions ΓòÉΓòÉΓòÉ
  7561.  
  7562. XDS contains the definition modules which correspond to some of the standard C 
  7563. header files. These currently include: 
  7564.  
  7565. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7566.  ctype   provides predicates to test a given value of the character type
  7567.  
  7568.  float   implementation limits for float numbers
  7569.  
  7570.  limits  implementation limits for whole numbers
  7571.  
  7572.  math    mathematical functions
  7573.  
  7574.  setjmp  set jump/long jump
  7575.  
  7576.  signal  signals
  7577.  
  7578.  stdio   standard input/output
  7579.  
  7580.  stdlib  standard library functions
  7581.  
  7582.  string  string manipulations
  7583.  
  7584.  time    time manipulations
  7585. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  7586.  
  7587. For a full description of these libraries, please refer to your C compiler 
  7588. library reference manual. 
  7589.  
  7590.  
  7591. ΓòÉΓòÉΓòÉ 12. Run-time Support ΓòÉΓòÉΓòÉ
  7592.  
  7593. Some language features are implemented in a run-time support library, including 
  7594.  
  7595.      exceptions and finalization 
  7596.  
  7597.      coroutines 
  7598.  
  7599.      memory management 
  7600.  
  7601.      garbage collection 
  7602.  
  7603.      postmorten history 
  7604.  
  7605.  XDS provides an integrated Modula-2 and Oberon-2 run-time library, taking into 
  7606.  account the possibility that modules written in both languages are used in one 
  7607.  project. As a rule, if you do not use any feature the part of RTS that 
  7608.  implements this feature will not be added to your executable program. For 
  7609.  example, if you program is written in Modula-2 only, the Oberon part of RTS 
  7610.  (garbage collector, meta-language facilities) will not included. 
  7611.  
  7612.  The integrated memory manager is described in Memory management. The section 
  7613.  The oberonRTS module describes an interface to the Oberon-2 run-time support. 
  7614.  
  7615.      Memory management 
  7616.      History 
  7617.      The oberonRTS module 
  7618.  
  7619.  
  7620. ΓòÉΓòÉΓòÉ 12.1. Memory management ΓòÉΓòÉΓòÉ
  7621.  
  7622. The XDS integrated memory manager implements 
  7623.  
  7624.      default memory allocation and deallocation procedures for Modula-2 (See 
  7625.       the option STORAGE); 
  7626.  
  7627.      the memory allocation procedure for Oberon-2; 
  7628.  
  7629.      the system memory allocation procedure for Oberon-2 (See NEW and 
  7630.       DISPOSE); 
  7631.  
  7632.      the garbage collector. 
  7633.  
  7634.  The XDS provides the GCAUTO option along with equations GCTHRESHOLD and 
  7635.  HEAPLIMIT to control the memory management. The option and equations should be 
  7636.  set when the top-level module of the program is compiled We recommend to set 
  7637.  them into the configuration or project file.. The XDS uses their values when 
  7638.  generating the call of RTS initialization. 
  7639.  
  7640.  The option GCAUTO allows the garbage collector to be called implicitly. If the 
  7641.  option is not set the garbage collector must be called explicitly (See The 
  7642.  oberonRTS module). The garbage collector is called implicitly by the memory 
  7643.  allocation procedure in the following cases: 
  7644.  
  7645.      a memory block of a required length cannot be allocated; 
  7646.  
  7647.      the amount of a busy memory exceeds the limit specified by the HEAPLIMIT 
  7648.       equation; 
  7649.  
  7650.      the amount of a busy memory exceeds the threshold specified by the 
  7651.       GCTHRESHOLD equation. 
  7652.  
  7653.  If the memory cannot be allocated after the call of the garbage collector, an 
  7654.  exception is raised, for a call from Oberon-2. 
  7655.  
  7656.  
  7657. ΓòÉΓòÉΓòÉ 12.2. History ΓòÉΓòÉΓòÉ
  7658.  
  7659. If the option GENHISTORYis set ON when compiling your program, the run-time 
  7660. system prints a stack of procedure calls on abnormal termination of your 
  7661. program, including 
  7662.  
  7663.      a file name 
  7664.  
  7665.      a line number 
  7666.  
  7667.      a program counter value 
  7668.  
  7669.      a procedure name (sometimes) 
  7670.  
  7671.  Note: all modules constituting your program should be compiled with the option 
  7672.  LINENO set ON. 
  7673.  
  7674.  To print the history, RTS scans the procedure stack of the coroutine that 
  7675.  caused an exception and tries to find procedure calls. This is not trivial 
  7676.  because of the highly optimized code generated by the compiler. For example, 
  7677.  not all procedures have a stack frame. 
  7678.  
  7679.  For each pointer to the code segment on the stack RTS checks the previous 
  7680.  command. If this command is a call command, it decides that this is a 
  7681.  procedure call. It is unlikely that RTS misses a procedure call, but it can be 
  7682.  cheated by something that looks like a procedure call. As a rule, it is caused 
  7683.  by uninitialized variables. 
  7684.  
  7685.  The first line of the history is always correct. For each line, except the 
  7686.  first, we recommend to check that the procedure shown in the previous line is 
  7687.  called from the given line. 
  7688.  
  7689.  From the other hand, if you turn the GENFRAME option on, the code will be a 
  7690.  bit slower, but RTS will scan stack frames of the procedures and the history 
  7691.  will show absolutely correct addresses and line numbers. Procedure names are 
  7692.  almost always valid except the case of lack of debug information in some 
  7693.  modules - probably compiled by foreign compilers or by XDS with not all debug 
  7694.  flags set. So you should not rely on procedure names hard. 
  7695.  
  7696.  Turning the GENHISTORY option on does not slow down your code, cause it only 
  7697.  adds one extra call to the initialization routine. It should be done when you 
  7698.  compile the main module of your program, in its header, compiler command line, 
  7699.  or project (we recommend the last approach). 
  7700.  
  7701.  The following example shows a sketch of the program and the procedure stack: 
  7702.  
  7703.   PROCEDURE P1;
  7704.     (* uninitialized variable: *)
  7705.     VAR x: ARRAY [0..50] OF INTEGER;
  7706.   BEGIN
  7707.     i:=i DIV j;   (* line 50 *)
  7708.   END P1;
  7709.  
  7710.   PROCEDURE P2;
  7711.   BEGIN
  7712.     i:=i DIV j;   (* line 100 *)
  7713.   END P2;
  7714.  
  7715.   PROCEDURE P3;
  7716.   BEGIN
  7717.     P1;           (* line 150 *)
  7718.   END P3;
  7719.  
  7720.   #RTS: No exception handler #6: zero or negative divisor
  7721.   ------------------------------------------------------------
  7722.   Source file                        LINE  OFFSET  PROCEDURE
  7723.   ------------------------------------------------------------
  7724.   "test.mod"                           50 000000DE
  7725.   "test.mod"                          100 0000024C
  7726.   "test.mod"                          150 0000051D
  7727.  
  7728.  It is obvious from the source text that the procedure P1 cannot be called from 
  7729.  P2. The second line is superfluous. 
  7730.  
  7731.  
  7732. ΓòÉΓòÉΓòÉ 12.3. The oberonRTS module ΓòÉΓòÉΓòÉ
  7733.  
  7734. The run time support (RTS) is an integral part of the Oberon-2 language 
  7735. implementation. It includes the command activation, memory allocation, garbage 
  7736. collection and meta-language facilities. The module oberonRTS provides an 
  7737. interface to these features. 
  7738.  
  7739.      Types and variables 
  7740.      Garbage collection 
  7741.      Object finalization 
  7742.      Meta-language facilities 
  7743.      Module iterators 
  7744.  
  7745.  
  7746. ΓòÉΓòÉΓòÉ 12.3.1. Types and variables ΓòÉΓòÉΓòÉ
  7747.  
  7748. TYPE
  7749.   Module;  (* run-time data structure for a module *)
  7750.   Type;    (* run-time data structure for a data type *)
  7751.   Command = PROC; (* parameterless procedure *)
  7752.   CARDINAL = SYSTEM.CARD32;
  7753.  
  7754. VAR
  7755.   nullModule: Module; (* Null value of type Module *)
  7756.   nullType: Type;     (* Null value of type Type *)
  7757.  
  7758.  
  7759. ΓòÉΓòÉΓòÉ 12.3.2. Garbage collection ΓòÉΓòÉΓòÉ
  7760.  
  7761.      Collect - Garbage Collector 
  7762.      GetInfo - Get Memory Information 
  7763.  
  7764.  
  7765. ΓòÉΓòÉΓòÉ 12.3.2.1. Collect - Garbage Collector ΓòÉΓòÉΓòÉ
  7766.  
  7767. PROCEDURE Collect;
  7768.  
  7769. Invokes the garbage collector. 
  7770.  
  7771.  
  7772. ΓòÉΓòÉΓòÉ 12.3.2.2. GetInfo - Get Memory Information ΓòÉΓòÉΓòÉ
  7773.  
  7774. PROCEDURE GetInfo(VAR objects, busymem: CARDINAL);
  7775.  
  7776. Returns the number of allocated objects and the total size of the allocated 
  7777. memory. 
  7778.  
  7779.  
  7780. ΓòÉΓòÉΓòÉ 12.3.3. Object finalization ΓòÉΓòÉΓòÉ
  7781.  
  7782. A system with garbage collection has some specific features. Its main 
  7783. difference from other systems is that deallocation of any system resource must 
  7784. be postponed until garbage collection. For example, let some data structure 
  7785. contain descriptors of open files. To close a file (i.e. to destroy its 
  7786. descriptor), one needs to know that there are no references to this file. This 
  7787. information becomes known only in the course of garbage collection. The same 
  7788. argument also holds for other kinds of resources. 
  7789.  
  7790. One immediate implication is that there must be some finalization mechanism: 
  7791. the ability to perform certain operations with an object when there are no more 
  7792. references to it. 
  7793.  
  7794. The XDS allows one to attach a finalization procedure to any object. 
  7795.  
  7796.      Finalizer - Type of a finalization procedure 
  7797.      InstallFinalizer - Set a finalizer to an object 
  7798.  
  7799.  
  7800. ΓòÉΓòÉΓòÉ 12.3.3.1. Finalizer - Type of a finalization procedure ΓòÉΓòÉΓòÉ
  7801.  
  7802. TYPE Finalizer = PROCEDURE (SYSTEM.ADDRESS);
  7803.  
  7804.  
  7805. ΓòÉΓòÉΓòÉ 12.3.3.2. InstallFinalizer - Set a finalizer to an object ΓòÉΓòÉΓòÉ
  7806.  
  7807. PROCEDURE InstallFinalizer(f: Finalizer; obj: SYSTEM.ADDRESS);
  7808.  
  7809. The procedure sets a finalization procedure "f" for object "obj". This 
  7810. procedure is called when the object becomes unreachable. Note: a finalizer is 
  7811. called on GC stack (stack size is limited); 
  7812.  
  7813.      Example 
  7814.  
  7815.  Example 
  7816.  
  7817.   TYPE
  7818.     Obj = POINTER TO ObjDesc;
  7819.     ObjDesc = RECORD
  7820.       file: File; (* file handler *)
  7821.     END;
  7822.  
  7823.   PROCEDURE Final(x: SYSTEM.ADDRESS);
  7824.     VAR o: Obj;
  7825.   BEGIN
  7826.     o:=SYSTEM.CAST(Obj,x);
  7827.     IF o.file # NIL THEN Close(file) END;
  7828.   END Final;
  7829.  
  7830.   PROCEDURE Create(): Obj;
  7831.     VAR o: Obj;
  7832.   BEGIN
  7833.     NEW(o);
  7834.     o.file:=NIL;
  7835.     oberonRTS.InstallFinalizer(Final,o);
  7836.     TryOpen(o.file);
  7837.   END Create;
  7838.  
  7839.  
  7840. ΓòÉΓòÉΓòÉ 12.3.4. Meta-language facilities ΓòÉΓòÉΓòÉ
  7841.  
  7842. The meta-programming operations allow one to retrieve the type of an object, to 
  7843. create an object of a given type, to get the name of a type and a type by its 
  7844. name, etc. 
  7845.  
  7846.      Search - Search a Module by its Name 
  7847.      NameOfModule - Name of Module 
  7848.      ThisCommand - Get Command by its Name 
  7849.      ThisType - Get Type by its Name 
  7850.      SizeOf - Size of Type 
  7851.      BaseOf - Base of Type 
  7852.      LevelOf - Level of Type Extension 
  7853.      ModuleOf - Module of Type 
  7854.      NameOfType - Name of Type 
  7855.      TypeOf - Type of Object 
  7856.      New Object - Create Object 
  7857.  
  7858.  
  7859. ΓòÉΓòÉΓòÉ 12.3.4.1. Search - Search a Module by its Name ΓòÉΓòÉΓòÉ
  7860.  
  7861. PROCEDURE Search(name: ARRAY OF CHAR): Module;
  7862.  
  7863. Returns a module by its name or nullModule. 
  7864.  
  7865.  
  7866. ΓòÉΓòÉΓòÉ 12.3.4.2. NameOfModule - Name of Module ΓòÉΓòÉΓòÉ
  7867.  
  7868. PROCEDURE NameOfModule(m: Module;
  7869.                 VAR name: ARRAY OF CHAR);
  7870.  
  7871. Returns the name of the module. 
  7872.  
  7873.  
  7874. ΓòÉΓòÉΓòÉ 12.3.4.3. ThisCommand - Get Command by its Name ΓòÉΓòÉΓòÉ
  7875.  
  7876. PROCEDURE ThisCommand(m: Module;
  7877.                    name: ARRAY OF CHAR;
  7878.                      ): Command;
  7879.  
  7880. Returns a command (parameterless procedure) named name in the module m or NIL, 
  7881. if such a command does not exist. 
  7882.  
  7883.  
  7884. ΓòÉΓòÉΓòÉ 12.3.4.4. ThisType - Get Type by its Name ΓòÉΓòÉΓòÉ
  7885.  
  7886. PROCEDURE ThisType(m: Module;
  7887.                 name: ARRAY OF CHAR): Type;
  7888.  
  7889. Returns a type declared in the module m or nullType, if such type does not 
  7890. exist. 
  7891.  
  7892.  
  7893. ΓòÉΓòÉΓòÉ 12.3.4.5. SizeOf - Size of Type ΓòÉΓòÉΓòÉ
  7894.  
  7895. PROCEDURE SizeOf(t: Type): INTEGER;
  7896.  
  7897. Returns the size (in bytes) of an object of the type t. 
  7898.  
  7899.  
  7900. ΓòÉΓòÉΓòÉ 12.3.4.6. BaseOf - Base of Type ΓòÉΓòÉΓòÉ
  7901.  
  7902. PROCEDURE BaseOf(t: Type; level: INTEGER): Type;
  7903.  
  7904. Returns the level-th base type of t. 
  7905.  
  7906.  
  7907. ΓòÉΓòÉΓòÉ 12.3.4.7. LevelOf - Level of Type Extension ΓòÉΓòÉΓòÉ
  7908.  
  7909. PROCEDURE LevelOf(t: Type): INTEGER;
  7910.  
  7911. Returns a level of the type extension. 
  7912.  
  7913.  
  7914. ΓòÉΓòÉΓòÉ 12.3.4.8. ModuleOf - Module of Type ΓòÉΓòÉΓòÉ
  7915.  
  7916. PROCEDURE ModuleOf(t: Type): Module;
  7917.  
  7918. Returns the module in which the type t was declared. 
  7919.  
  7920.  
  7921. ΓòÉΓòÉΓòÉ 12.3.4.9. NameOfType - Name of Type ΓòÉΓòÉΓòÉ
  7922.  
  7923. PROCEDURE NameOfType(t: Type; VAR name: ARRAY OF CHAR);
  7924.  
  7925. Returns the name of the record type. 
  7926.  
  7927.  
  7928. ΓòÉΓòÉΓòÉ 12.3.4.10. TypeOf - Type of Object ΓòÉΓòÉΓòÉ
  7929.  
  7930. PROCEDURE TypeOf(obj: SYSTEM.ADDRESS): Type;
  7931.  
  7932. Returns the type of the object. 
  7933.  
  7934.  
  7935. ΓòÉΓòÉΓòÉ 12.3.4.11. New Object - Create Object ΓòÉΓòÉΓòÉ
  7936.  
  7937. PROCEDURE NewObj(type: Type): SYSTEM.ADDRESS;
  7938.  
  7939. Creates a new object of the type t. 
  7940.  
  7941.  
  7942. ΓòÉΓòÉΓòÉ 12.3.5. Module iterators ΓòÉΓòÉΓòÉ
  7943.  
  7944. The module provides iterators which allow one to iterate all loaded modules, 
  7945. all commands and all object types (i.e., exported record types). 
  7946.  
  7947.      NameIterator - Iterator Type 
  7948.      IterModules - Iterate all Modules 
  7949.      IterCommands - Iterate Commands 
  7950.      IterTypes - Iterate Record Types 
  7951.  
  7952.  
  7953. ΓòÉΓòÉΓòÉ 12.3.5.1. NameIterator - Iterator Type ΓòÉΓòÉΓòÉ
  7954.  
  7955. TYPE
  7956.   NameIterator = PROCEDURE (
  7957.                    (*context:*) SYSTEM.ADDRESS,
  7958.                    (*name:*) ARRAY OF CHAR
  7959.                  ): BOOLEAN;
  7960.  
  7961. The NameIterator is called by an iterator on each iterated item. An iterator 
  7962. passes the name of the item along with the so-called context word. This allows 
  7963. some context information to be passed to the user-defined procedure (e.g., the 
  7964. file handler). If the iterated procedure returns FALSE, the iteration is broken 
  7965. off. 
  7966.  
  7967.  
  7968. ΓòÉΓòÉΓòÉ 12.3.5.2. IterModules - Iterate all Modules ΓòÉΓòÉΓòÉ
  7969.  
  7970. PROCEDURE IterModules(context: SYSTEM.ADDRESS;
  7971.                          iter: NameIterator);
  7972.  
  7973. The procedure iterates all Oberon-2 modules. 
  7974.  
  7975.  
  7976. ΓòÉΓòÉΓòÉ 12.3.5.3. IterCommands - Iterate Commands ΓòÉΓòÉΓòÉ
  7977.  
  7978. PROCEDURE IterCommands(mod: Module;
  7979.                    context: SYSTEM.ADDRESS;
  7980.                       iter: NameIterator);
  7981.  
  7982. Iterates all commands implemented in the module mod. 
  7983.  
  7984.  
  7985. ΓòÉΓòÉΓòÉ 12.3.5.4. IterTypes - Iterate Record Types ΓòÉΓòÉΓòÉ
  7986.  
  7987. PROCEDURE IterTypes(mod: Module;
  7988.                 context: SYSTEM.WORD;
  7989.                    iter: NameIterator);
  7990.  
  7991. Iterates all record types declared in the module mod. 
  7992.  
  7993.  
  7994. ΓòÉΓòÉΓòÉ 13. Configuring XDS for a C Compiler ΓòÉΓòÉΓòÉ
  7995.  
  7996. XDS allows C functions and libraries to be used in your projects. Different C 
  7997. compilers have different naming and calling conventions. You have to specify 
  7998. your C compiler in XDS environment using the CC equation. The equation forces 
  7999. XDS to call all C functions in a way compatible with the specified C compiler. 
  8000. Also the compiler sets the default values of additional configuration options 
  8001. according to the value of the equation. See Additional configuration options. 
  8002.  
  8003. Alignment of data structures is controlled by the ALIGNMENT option. If this 
  8004. option is off all data structures are treated as not aligned and when this 
  8005. option is on all data stuctures are treated as aligned. 
  8006.  
  8007. Names in an object file produced by a C compiler may have leading underscore. 
  8008. If you are going to use C modules and libraries you have to force XDS to use 
  8009. the same naming rules. To do this, turn GENCPREF option ON in the configuration 
  8010. file: 
  8011.  
  8012. +GENCPREF
  8013.  
  8014. See samples.txt from XDS on-line documentation for more information. 
  8015.  
  8016.      Possible problems 
  8017.      Using unsupported compiler 
  8018.      Additional configuration options 
  8019.  
  8020.  
  8021. ΓòÉΓòÉΓòÉ 13.1. Possible problems ΓòÉΓòÉΓòÉ
  8022.  
  8023. To use a C function or a data type from Modula-2 or Oberon-2 one have to 
  8024. express its type in one of these languages. Usually it is done in a foreign 
  8025. definition module (See Interfacing to C). The current version of XDS does not 
  8026. support all calling conventions, thats why using of some functions is 
  8027. impossible, namely: 
  8028.  
  8029.      functions with parameter of a structured type, passed by value, e.g.: 
  8030.  
  8031.             void foo(struct MyStruct s)
  8032.  
  8033.      functions that return structured types, e.g.: 
  8034.  
  8035.             struct MyStruct foo(void)
  8036.  
  8037.      C functions with Pascal calling convention that return the real type. 
  8038.  
  8039.      functions that are compiled with non-stack calling conventions. Note: 
  8040.       stack calling conventions shall be set for Watcom using "-3s", "-4s" or 
  8041.       "-5s" option. 
  8042.  
  8043.  XDS does not support the use of data structures with non-standard alignment. 
  8044.  If the ALIGNMENT option is off, use the option "-zp1" for Watcom C and "-Zp1" 
  8045.  for MSVC. Otherwise, use "-zp4" (Watcom) and "-Zp4" (MSVC). 
  8046.  
  8047.  Both Modula-2 and C/C++ have exception handling and finalization facilities. 
  8048.  Unpredictable results may occur if you try to use facilities from both 
  8049.  languages in one program. 
  8050.  
  8051.  
  8052. ΓòÉΓòÉΓòÉ 13.2. Using unsupported compiler ΓòÉΓòÉΓòÉ
  8053.  
  8054. XDS does not support all available C compilers. You can use additional 
  8055. configuration options (See Additional configuration options) to adapt XDS to 
  8056. your compiler. The DEFLIBS option should be switched off in that case. 
  8057.  
  8058. It may be necessary to make some changes in the run-time support for the 
  8059. particular extender. It can be done in terms of our support program. 
  8060.  
  8061.  
  8062. ΓòÉΓòÉΓòÉ 13.3. Additional configuration options ΓòÉΓòÉΓòÉ
  8063.  
  8064. Additional configuration options can be used to adapt XDS to unsupported C 
  8065. compiler. We recommend to use these options with care. 
  8066.  
  8067.  GENCPREF 
  8068.  
  8069.            If the option is ON, the compiler appends underscore as a prefix for 
  8070.            all names in object files. 
  8071.  
  8072.  ONECODESEG 
  8073.  
  8074.            If the option is ON, the compiler produces only one code segment 
  8075.            which contains all code of a module, otherwise it generates separate 
  8076.            code segment for each procedure. 
  8077.  
  8078.  The table below shows the default values of these options for the supported C 
  8079.  compilers: 
  8080.  
  8081.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8082.    Option      WATCOM  MSVC
  8083.  
  8084.    GENCPREF    OFF     ON
  8085.  
  8086.    ONECODESEG  OFF     ON
  8087.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8088.  
  8089.  
  8090. ΓòÉΓòÉΓòÉ 14. Low-level Programming ΓòÉΓòÉΓòÉ
  8091.  
  8092.      Data representation 
  8093.      Sequence parameters 
  8094.  
  8095.  
  8096. ΓòÉΓòÉΓòÉ 14.1. Data representation ΓòÉΓòÉΓòÉ
  8097.  
  8098. The internal representation of values of Modula-2 and Oberon-2 basic types is 
  8099. described in the tables Data representation and Data representation. In the 
  8100. table Data representation a representation of system types is described. 
  8101.  
  8102. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8103.  Modula-2 type  Bits   Representation
  8104.  
  8105.  SHORTINT       8      signed
  8106.  
  8107.  INTEGER        16/32  signed (See Modula-2 INTEGER and CARDINAL types)
  8108.  
  8109.  LONGINT        32     signed
  8110.  
  8111.  SHORTCARD      8      unsigned
  8112.  
  8113.  CARDINAL       16/32  unsigned (See Modula-2 INTEGER and CARDINAL types)
  8114.  
  8115.  LONGCARD       32     unsigned
  8116.  
  8117.  CHAR           8      unsigned
  8118.  
  8119.  BOOLEAN        8/32   unsigned (See Modula-2 BOOLEAN type)
  8120.  
  8121.                        0 for FALSE, 1 for TRUE
  8122.  
  8123.  subranges             according to the base type
  8124.  
  8125.  REAL           32     80387 single-precision data format
  8126.  
  8127.  LONGREAL       64     80387 double-precision data format
  8128. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8129.  
  8130. Representation of Modula-2 basic types 
  8131.  
  8132. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8133.  Oberon-2 type  Bits  Representation
  8134.  
  8135.  SHORTINT       8     signed
  8136.  
  8137.  INTEGER        16    signed
  8138.  
  8139.  LONGINT        32    signed
  8140.  
  8141.  CHAR           8     unsigned
  8142.  
  8143.  BOOLEAN        8     unsigned byte
  8144.  
  8145.                       0 for FALSE, 1 for TRUE
  8146.  
  8147.  REAL           32    80387 single-precision data format
  8148.  
  8149.  LONGREAL       64    80387 double-precision data format
  8150.  
  8151.  SET            32    unsigned
  8152. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8153.  
  8154. Representation of Oberon-2 basic types 
  8155.  
  8156. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8157.  System type  Bits  Representation
  8158.  
  8159.  ADDRESS      32    unsigned
  8160.  
  8161.  BOOL8        8     unsigned
  8162.  
  8163.  BOOL32       32    unsigned
  8164.  
  8165.  BYTE         8     unsigned
  8166.  
  8167.  CARD8        8     unsigned
  8168.  
  8169.  CARD16       16    unsigned
  8170.  
  8171.  CARD32       32    unsigned
  8172.  
  8173.  INT8         8     signed
  8174.  
  8175.  INT16        16    signed
  8176.  
  8177.  INT32        32    signed
  8178.  
  8179.  LOC          8     unsigned
  8180.  
  8181.  WORD         32    ARRAY [0..3] OF LOC
  8182. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8183.  
  8184. Representation of SYSTEM types 
  8185.  
  8186.      Modula-2 INTEGER and CARDINAL types 
  8187.      Modula-2 BOOLEAN type 
  8188.      Modula-2 enumeration types 
  8189.      Modula-2 set types 
  8190.      Pointer, address and opaque types 
  8191.      Procedure types 
  8192.      Record types 
  8193.      Array types 
  8194.  
  8195.  
  8196. ΓòÉΓòÉΓòÉ 14.1.1. Modula-2 INTEGER and CARDINAL types ΓòÉΓòÉΓòÉ
  8197.  
  8198. If the option M2BASE16 is OFF, INTEGER and CARDINAL types are represented as 
  8199. 32-bit values, otherwise as 16-bit values. 
  8200.  
  8201.  
  8202. ΓòÉΓòÉΓòÉ 14.1.2. Modula-2 BOOLEAN type ΓòÉΓòÉΓòÉ
  8203.  
  8204. If the option M2UNPACKTYPES is OFF, boolean type is represented as unsigned 
  8205. 1-byte value, otherwise as unsigned 32-bit value. 
  8206.  
  8207.  
  8208. ΓòÉΓòÉΓòÉ 14.1.3. Modula-2 enumeration types ΓòÉΓòÉΓòÉ
  8209.  
  8210. If the option M2UNPACKTYPES is OFF, Modula-2 enumeration types of no more than 
  8211. 256 and 65536 elements are represented as unsigned 1 or 2-byte values 
  8212. respectively. Otherwise, enumerations are represented as 4-byte values. 
  8213.  
  8214.  
  8215. ΓòÉΓòÉΓòÉ 14.1.4. Modula-2 set types ΓòÉΓòÉΓòÉ
  8216.  
  8217. If the option M2UNPACKTYPES is OFF, Modula-2 sets of no more than 8, 16 and 32 
  8218. elements are represented as unsigned 1, 2 or 4-byte values respectively. 
  8219. Otherwise, sets of no more than 32 elements are represented as 4-byte values. 
  8220.  
  8221. If the option M2BASE16 is OFF, BITSET type is represented as unsigned 32-bit 
  8222. values, otherwise as 16-bit values. 
  8223.  
  8224.  
  8225. ΓòÉΓòÉΓòÉ 14.1.5. Pointer, address and opaque types ΓòÉΓòÉΓòÉ
  8226.  
  8227. Address types are represented as 32-bit (4-byte) unsigned values containing the 
  8228. byte offset in the task data segment. The address arithmetic is implemented as 
  8229. 32-bit unsigned arithmetic without overflow checks. 
  8230.  
  8231.  
  8232. ΓòÉΓòÉΓòÉ 14.1.6. Procedure types ΓòÉΓòÉΓòÉ
  8233.  
  8234. Procedure types are represented by the 32-bit (4-byte) address of the 
  8235. procedure's entry point in the task code segment. 
  8236.  
  8237.  
  8238. ΓòÉΓòÉΓòÉ 14.1.7. Record types ΓòÉΓòÉΓòÉ
  8239.  
  8240. Records are represented by a continuous memory segment containing all record 
  8241. components (fields) in a representation corresponding to their type. If the 
  8242. option ALIGNMENT is ON, the compiler aligns each field according to its size. 
  8243. It aligns a 2-byte value to an even offset and a value of 4 or more bytes to an 
  8244. offset divisible by 4. A record itself is aligned according to its field with 
  8245. largest alignment, e.g. if a record contains a field of the REAL type, its size 
  8246. will be multiple of 4 (SIZE(REAL) = 4). 
  8247.  
  8248.  
  8249. ΓòÉΓòÉΓòÉ 14.1.8. Array types ΓòÉΓòÉΓòÉ
  8250.  
  8251. An array is represented by a continuous memory segment containing all array 
  8252. elements in a representation corresponding to their type. 
  8253.  
  8254. Note that elements within an array could be aligned so, that in general for 
  8255.  
  8256.   TYPE A = ARRAY [0..N-1] OF T;
  8257.  
  8258. SIZE(A) is not equal to SIZE(T) * N. 
  8259.  
  8260. Open arrays, as well as procedure formal parameters of type ARRAY OF ... ARRAY 
  8261. OF T, are represented by an open array descriptor. For an N-dimensional open 
  8262. array, the descriptor is an array of 3N 32-bit elements, which are: 
  8263.  
  8264.      the first element the address of the array proper; 
  8265.  
  8266.      for each of N-1 higher dimensions, the descriptor contains three 
  8267.       consecutive signed integers, which are: 
  8268.  
  8269.         -  the lowest array index of this dimension (always 0); 
  8270.  
  8271.         -  the highest array index (the length of this dimension minus one); 
  8272.  
  8273.         -  the size of the array element in bytes; 
  8274.  
  8275.      for the last dimension, the array descriptor contains its lowest (0) and 
  8276.       highest indices. 
  8277.  
  8278.  Example: 
  8279.  
  8280.  let A be an open 3-dimensional array of INTEGER (SIZE(INTEGER)=2 in Oberon-2) 
  8281.  created as 
  8282.  
  8283.     NEW(A,4,3,6)
  8284.  
  8285.  then its descriptor is a 9-element array containing: 
  8286.  
  8287.        #0:  Address of array itself
  8288.        #1:   0
  8289.        #2:   3   (4-1)
  8290.        #3:  36   (12*3)
  8291.        #4:   0
  8292.        #5:   2   (3-1)
  8293.        #6:  12   (6*2)
  8294.        #7:   0
  8295.        #8:   5   (6-1)
  8296.  
  8297.  
  8298. ΓòÉΓòÉΓòÉ 14.2. Sequence parameters ΓòÉΓòÉΓòÉ
  8299.  
  8300. The array of bytes which is passed to a procedure in place of a formal 
  8301. SEQ-parameter is formed as follows: 
  8302.  
  8303.      values of all actual parameters forming the sequence are represented as 
  8304.       described below and concatenated in the array in their textual order 
  8305.  
  8306.      integer values are converted to LONGINT 
  8307.  
  8308.      BOOLEAN, CHAR, cardinal and enumeration values are converted to LONGCARD 
  8309.  
  8310.      range type values are converted according to their base type 
  8311.  
  8312.      real values are converted to LONGREAL 
  8313.  
  8314.      pointer, address, opaque and procedure type values are converted to 
  8315.       ADDRESS 
  8316.  
  8317.      structured value (record or array) is interpreted as one-dimensional 
  8318.       array of bytes and then is represented by an array descriptor (See Data 
  8319.       representation). 
  8320.  
  8321.  Example 
  8322.  
  8323.       PROCEDURE write(SEQ args: SYSTEM.BYTE);
  8324.       BEGIN
  8325.       END write;
  8326.  
  8327.       VAR i: INTEGER;
  8328.           c: SYSTEM.CARD8;
  8329.           r: LONGREAL;
  8330.           S: RECORD a: LONGINT; c: CHAR END;
  8331.           p: POINTER TO ARRAY OF CHAR;
  8332.       ...
  8333.  
  8334.       write(i,c,S,r,p^);
  8335.  
  8336.  For this call the actual byte array passed to write will contain: 
  8337.  
  8338.      4 bytes of the sign-extended value of i 
  8339.  
  8340.      4 bytes of the zero-extended value of c 
  8341.  
  8342.      12 bytes of the array descriptor 
  8343.  
  8344.         -  4 bytes containing the address of S 
  8345.  
  8346.         -  4 bytes containing 0 
  8347.  
  8348.         -  4 bytes containing 4 (SIZE(S)-1) 
  8349.  
  8350.      8 bytes value of r in the double-precision 80387 format 
  8351.  
  8352.      12 bytes of the array descriptor 
  8353.  
  8354.         -  4 bytes containing the address of array of CHAR itself 
  8355.  
  8356.         -  4 bytes containing value 0 
  8357.  
  8358.         -  4 bytes containing SIZE(p^)-1 
  8359.  
  8360.  
  8361. ΓòÉΓòÉΓòÉ 15. Implementation limitations and restrictions ΓòÉΓòÉΓòÉ
  8362.  
  8363. There are some limitations and restrictions in both Modula-2 and Oberon-2 
  8364. compilers. 
  8365.  
  8366.      Length of identifiers 
  8367.      Length of literal strings 
  8368.      Record extension hierarchy 
  8369.      Unimplemented ISO libraries 
  8370.      Unimplemented Oakwood libraries 
  8371.      Coroutines 
  8372.      Dynamic loader 
  8373.  
  8374.  
  8375. ΓòÉΓòÉΓòÉ 15.1. Length of identifiers ΓòÉΓòÉΓòÉ
  8376.  
  8377. The length of an identifier is at most 127 characters. 
  8378.  
  8379.  
  8380. ΓòÉΓòÉΓòÉ 15.2. Length of literal strings ΓòÉΓòÉΓòÉ
  8381.  
  8382. The length of a literal string is at most 256 characters. Longer strings may be 
  8383. constructed by use of the string concatenation operator (See Strings). 
  8384.  
  8385.  
  8386. ΓòÉΓòÉΓòÉ 15.3. Record extension hierarchy ΓòÉΓòÉΓòÉ
  8387.  
  8388. The length of a record extension hierarchy is at most 15 extensions. 
  8389.  
  8390.  
  8391. ΓòÉΓòÉΓòÉ 15.4. Unimplemented ISO libraries ΓòÉΓòÉΓòÉ
  8392.  
  8393. The TermFile Modula-2 ISO standard library module is not available in the 
  8394. current release. 
  8395.  
  8396.  
  8397. ΓòÉΓòÉΓòÉ 15.5. Unimplemented Oakwood libraries ΓòÉΓòÉΓòÉ
  8398.  
  8399. The following Oberon-2 Oakwood library modules are not available in the current 
  8400. release: 
  8401.  
  8402. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8403.  Input    Keyboard and pointer device access
  8404.  
  8405.  Files    File input/output, riders
  8406.  
  8407.  XYPlane  Elementary pixel plotting
  8408. ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  8409.  
  8410.  
  8411. ΓòÉΓòÉΓòÉ 15.6. Coroutines ΓòÉΓòÉΓòÉ
  8412.  
  8413. The current release provides a restricted implementation of the system module 
  8414. COROUTINES: the interrupt requests are not detected. 
  8415.  
  8416.  
  8417. ΓòÉΓòÉΓòÉ 15.7. Dynamic loader ΓòÉΓòÉΓòÉ
  8418.  
  8419. The Oberon-2 dynamic loading facility is not provided in the current release.